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:Main.java

/**
 * Write data row./*from  www . ja v  a2 s .  c  o m*/
 * 
 * @param data the data
 * @param outputPath the output path
 */
public static void writeDataRow(String data, String outputPath) {
    File file = new File(outputPath);
    try {
        file.createNewFile();
    } catch (IOException e1) {
        e1.printStackTrace();
        System.exit(0);
    }
    try {
        BufferedWriter writer = new BufferedWriter(new FileWriter(file));
        writer.write(data);
        writer.close();
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(0);
    }
}

From source file:com.reversemind.glia.test.go3.java

public static void save(String fileName, String string) throws Exception {

    BufferedWriter bw = new BufferedWriter(new FileWriter(new File(fileName)));
    bw.write(string + "\n");
    bw.flush();//from w w w .  j av a  2s. com
    bw.close();

}

From source file:Main.java

public static void write(String text, File dst) throws IOException {
    BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(dst));
    bufferedWriter.write(text);
    bufferedWriter.flush();//from ww  w  .jav a2 s . co  m
    bufferedWriter.close();
}

From source file:Main.java

public static Process execute(String command) throws Exception {
    final Process process = new ProcessBuilder("sh").redirectErrorStream(true).start();

    BufferedWriter stdOutput = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));

    stdOutput.write(command + "; exit\n");
    stdOutput.flush();//from  ww w.  j  a va2  s .  com
    stdOutput.close();

    return process;
}

From source file:Main.java

public static void writeWarning(BufferedWriter outputFileWriter, int lineCount, String errorMessage)
        throws IOException {
    outputFileWriter.write("Warning on line " + lineCount + " : ");
    outputFileWriter.write(errorMessage);
    outputFileWriter.newLine();/*from  w  ww.  ja v a2 s.  c  o m*/
}

From source file:Main.java

/**
 * Trims down obj files, so that they may be parsed faster later on.
 * Remove uneccessary whitespaces, comments etc.
 * @param in stream to be trimmed//from   w w  w  . ja va 2  s  . c  o m
 * @param out the resulting trimmed stream
 */
public static void trim(BufferedReader in, BufferedWriter out) throws IOException {
    String line;
    out.write("#trimmed\n");
    for (line = in.readLine(); line != null; line = in.readLine()) {
        line = getCanonicalLine(line);
        if (line.length() > 0) {
            out.write(line.trim());
            out.write('\n');
        }
    }
    in.close();
    out.close();
}

From source file:io.druid.query.aggregation.datasketches.tuple.GenerateTestData.java

private static void writeBucketTestRecord(BufferedWriter out, String label, int id, double parameter)
        throws Exception {
    out.write("20170101");
    out.write("\t");
    out.write(label);//from   w ww. j a  v  a2 s  .  co m
    out.write("\t");
    out.write(Integer.toString(id));
    out.write("\t");
    out.write(Double.toString(parameter));
    out.newLine();
}

From source file:at.ac.tuwien.dsg.cloudlyra.utils.IOUtils.java

public static void writeData(String data, String fileName) {

    String tomcatTempFolder = System.getProperty("java.io.tmpdir");
    //String tomcatTempFolder="/Volumes/DATA/BigData";
    fileName = tomcatTempFolder + "/" + fileName;
    FileWriter fstream;/*from ww w .ja  va 2s .  c  om*/
    try {
        fstream = new FileWriter(fileName, false);
        BufferedWriter out = new BufferedWriter(fstream);
        out.write(data);

        out.close();
    } catch (IOException ex) {
    }
}

From source file:com.egt.core.db.ddl.Writer.java

private static void execute(String vm, Map clases) {
    //      Utils.println("*** combinar(" + vm + ", clases=" + clases.size() + ") ***");
    if (clases == null || clases.size() == 0) {
        return;//from ww  w . j av  a2s. c  om
    }
    try {
        Template template = Velocity.getTemplate(vm);
        VelocityContext context = new VelocityContext();
        context.put("clases", clases);
        StringWriter sw = new StringWriter();
        template.merge(context, sw);
        String filename = vm.replace(".vm", ".sql");
        FileWriter fileWriter = new FileWriter(filename);
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
        bufferedWriter.write(sw.toString());
        bufferedWriter.close();
    } catch (ResourceNotFoundException ex) {
        ex.printStackTrace();
    } catch (ParseErrorException ex) {
        ex.printStackTrace();
    } catch (MethodInvocationException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static boolean writeXMLFile(String outFileName, String xmlFile) {
    BufferedWriter writer;
    try {/*from   w ww. ja va2  s . com*/
        writer = new BufferedWriter(new FileWriter(outFileName, false));
        writer.write(xmlFile);
        writer.close();
        return true;
    } catch (IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }
}