Example usage for java.io BufferedWriter write

List of usage examples for java.io BufferedWriter write

Introduction

In this page you can find the example usage for java.io BufferedWriter write.

Prototype

public void write(int c) throws IOException 

Source Link

Document

Writes a single character.

Usage

From source file:com.qmetry.qaf.automation.util.FileUtil.java

public static void appendFile(String fileName, StringBuffer sb) throws IOException {
    FileWriter fileWritter = new FileWriter(fileName, true);
    BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
    bufferWritter.write(sb.toString());
    bufferWritter.close();// w  w  w .  j  av  a 2 s  .c  om
}

From source file:org.openmrs.module.report.util.FileUtils.java

public static void WriteStringToFile(String str, String file) {

    try {// w ww.ja v  a 2 s  .c  o m
        BufferedWriter output = new BufferedWriter(new FileWriter(file));
        output.write(str);
        output.flush();
        output.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:es.sotileza.plugin.utils.Utilidades.java

public static void addXml(String xml, List<String> lineas) throws IOException {
    FileWriter output = new FileWriter(xml, true);
    BufferedWriter writer = new BufferedWriter(output);
    for (String i : lineas)
        writer.write(i + "\n");
    writer.flush();/*from  w  w w .j  a  v a2 s. co m*/
}

From source file:es.sotileza.plugin.utils.Utilidades.java

public static void paintFile(String file, List<String> lineas) throws IOException {
    FileWriter output = new FileWriter(file);
    BufferedWriter writer = new BufferedWriter(output);
    for (String i : lineas)
        writer.write(i + "\n");
    System.out.println("Generado el fichero: " + file);
    writer.flush();// ww  w.j  a  v a 2s.  c  o  m
}

From source file:eu.sisob.uma.footils.File.FileFootils.java

/**
 *
 * @param content//from  w  w  w  . ja  va2s .  c o  m
 * @param name
 * @param encode
 */
public static void writeFile(String content, String name, String encode)
        throws FileNotFoundException, UnsupportedEncodingException, IOException {
    File fField = new File(name);
    FileOutputStream fileOS;
    fileOS = new java.io.FileOutputStream(fField, false);
    OutputStreamWriter writer = new java.io.OutputStreamWriter(fileOS, encode);
    BufferedWriter bw = new java.io.BufferedWriter(writer);
    String sOut = content;
    bw.write(sOut);
    bw.close();
}

From source file:com.khepry.utilities.GenericUtilities.java

public static void generateOutFile(String outFilePath, String outputText, Handler handler) {
    Logger.getLogger("").addHandler(handler);
    File outFile = new File(outFilePath);
    if (outFile.getParentFile().exists()) {
        try {//from  www . j av  a  2  s  .  c  om
            BufferedWriter bw = new BufferedWriter(new FileWriter(outFilePath));
            bw.write(outputText);
            bw.close();
        } catch (IOException ex) {
            Logger.getLogger(GenericUtilities.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        Logger.getLogger(GenericUtilities.class.getName()).log(Level.SEVERE,
                "Output path: " + outFile.getParent() + " does not exist!", new FileNotFoundException());
    }
}

From source file:edu.indiana.d2i.htrc.util.Utilities.java

public static void Clean2Unclean(String input, String output) throws IOException {
    BufferedReader reader = new BufferedReader(new FileReader(input));
    BufferedWriter writer = new BufferedWriter(new FileWriter(output));

    Pairtree pairtree = new Pairtree();

    String line = null;//  www.ja  v  a  2s.c o m
    while ((line = reader.readLine()) != null) {
        writer.write(pairtree.uncleanId(line) + "\n");
    }

    writer.close();
    reader.close();
}

From source file:edu.umd.cs.findbugs.detect.LpUtil.java

public static void writerLog(Object... str) {
    BufferedWriter writer = null;
    try {//from w  w  w.  j a va 2 s  .  co m
        writer = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(new File("d:\\123000.txt"), true), UTF8.charset));
        for (Object temp : str) {
            writer.write(String.valueOf(temp));
            writer.write("\r\n");
        }
    } catch (Exception e) {
    } finally {
        try {
            if (writer != null) {
                writer.close();
            }
        } catch (IOException e) {
        }
    }
}

From source file:iics.Connection.java

static void create_dir() {

    try {//from  w  w  w  .  j  a v a 2 s.  c  o m
        File directory = new File(dir);
        if (directory.exists()) {
            create_file();

        } else {
            System.out.println("Directory not exists, creating now");

            success = directory.mkdir();
            if (success) {
                create_file();
            } else {
                System.out.printf("Failed to create new directory: %s%n", dir);
                JOptionPane.showMessageDialog(null,
                        "                 An error occured!! \n Contact your system admin for help.", null,
                        JOptionPane.WARNING_MESSAGE);
                close_loda();
            }
        }
        fw = new FileWriter(f.getAbsoluteFile());
        BufferedWriter bw = new BufferedWriter(fw);
        bw.write(content);
        bw.close();
    } catch (IOException ex) {
        //   Logger.getLogger(Extract.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null,
                "                 An error occured!! \n Contact your system admin for help.", null,
                JOptionPane.WARNING_MESSAGE);
        close_loda();
    } finally {
        try {
            fw.close();
        } catch (IOException ex) {
            //   Logger.getLogger(Extract.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null,
                    "                 An error occured!! \n Contact your system admin for help.", null,
                    JOptionPane.WARNING_MESSAGE);
            close_loda();
        }
    }
}

From source file:edgeserver.Publicador.java

private static void armazenaFila(ArrayList filaPublicacoes) throws IOException {
    new PrintWriter("fila.txt").close();
    filaPublicacoes.stream().forEach((publicacao) -> {
        BufferedWriter bw = null;
        try {//from   ww  w.  j a v  a  2s.c  om
            // APPEND MODE SET HERE
            bw = new BufferedWriter(new FileWriter("fila.txt", true));
            bw.write(publicacao.toString());
            bw.newLine();
            bw.flush();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        } finally { // always close the file
            if (bw != null)
                try {
                    bw.close();
                } catch (IOException ioe2) {
                    // just ignore it
                }
        }
    });

}