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:net.genesishub.gFeatures.Feature.gWarsSuite.Configs.CrackshotConfiguration.java

public void MakeFile(String filename) throws IOException {
    Reader paramReader = new InputStreamReader(
            getClass().getResourceAsStream("/net/genesishub/gFeatures/Feature/gWarsSuite/Configs/" + filename));
    StringWriter writer = new StringWriter();
    IOUtils.copy(paramReader, writer);//from ww w .  j av a  2  s. co m
    String theString = writer.toString();
    File f = new File("plugins/CrackShot/weapons/" + filename + ".yml");
    f.createNewFile();
    BufferedWriter bw = new BufferedWriter(new FileWriter(f));
    bw.write(theString);
    bw.close();
}

From source file:com.vmanolache.mqttpolling.Polling.java

private void sendPost() throws UnsupportedEncodingException, JSONException {
    try {//  w  ww . j av  a 2  s.  co  m
        String url = "http://localhost:8080/notifications";
        URL obj = new URL(url);
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();

        HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.setRequestProperty("Content-Type", "application/json");
        connection.setRequestMethod("POST");

        /**
         * POSTing *
         */
        OutputStream os = connection.getOutputStream();
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
        writer.write(getQuery()); // should be fine if my getQuery is encoded right yes?
        writer.flush();
        writer.close();
        os.close();
        connection.connect();

        int status = connection.getResponseCode();
        System.out.println(status);
    } catch (IOException ex) {
        Logger.getLogger(Polling.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:twitter4j.SpringCompatibilityTest.java

private void writeFile(String path, String content) throws IOException {
    File file = new File(path);
    file.delete();//from w w w .  ja  v  a  2 s .c om
    BufferedWriter bw = new BufferedWriter(new FileWriter(file));
    bw.write(content);
    bw.close();
}

From source file:gov.jgi.meta.MetaUtils.java

/**
 * given a map of sequences indexed by sequence id, write out a fasta file to local file system.
 * files are created with rwx bits set to 777.
 *
 * @param seqList is the list of sequences to create the database with
 * @param tmpFileName the file name/path to create
 * @return the full path of the location of the database
 * @throws IOException if error occures in file creation
 *//*from  w  w w .  j  av a  2  s  .c  om*/
public static String sequenceToLocalFile(Map<String, String> seqList, String tmpFileName) throws IOException {
    BufferedWriter out;
    File seqFile = null;

    /*
     * open temp file
     */
    seqFile = new File(tmpFileName);
    out = new BufferedWriter(new FileWriter(seqFile.getPath()));

    /*
     * write out the sequences to file
     */
    for (String key : seqList.keySet()) {
        assert (seqList.get(key) != null);
        out.write(">" + key + "\n");
        out.write(seqList.get(key) + "\n");
    }

    /*
     * close temp file
     */
    out.close();

    if (!(seqFile.setExecutable(true, false) && seqFile.setReadable(true, false)
            && seqFile.setWritable(true, false))) {
        throw new IOException("unable to set RWX bits to 777");
    }

    return (seqFile.getPath());
}

From source file:mattmc.mankini.commands.CommandQuote.java

private void addQuote(String content, MessageEvent<PircBotX> event) {
    try {//  ww w .  j  a v a2  s  . co m
        if (!file.exists()) {
            System.out.println(file.createNewFile());
        }

        FileWriter fw;

        fw = new FileWriter(file, true);

        BufferedWriter bw = new BufferedWriter(fw);
        bw.write(content);
        bw.newLine();
        bw.close();

        MessageSending.sendNormalMessage("Quote Added!", event);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.eleven0eight.xls2json.App.java

public void saveJson(String filename, String json) throws Exception {

    BufferedWriter out = new BufferedWriter(new FileWriter(filename));
    out.write(json);
    out.close();/*  w w  w  .  j av a 2 s . c  o m*/

}

From source file:net.sf.sessionAnalysis.SessionVisitorSessionLengthNumActionsStatistics.java

public void writeSessionsOverTime(final String outputDir) throws IOException {
    FileWriter fw = new FileWriter(outputDir + "/" + this.getClass().getSimpleName() + "-sessionLengths.csv");
    BufferedWriter writer = new BufferedWriter(fw);

    writer.write("length");
    writer.newLine();/*from w w  w .ja va 2  s  . c o m*/
    for (double l : this.computeLengthVector()) {
        writer.write(Double.toString(l));
        writer.newLine();
    }

    writer.close();
    fw.close();
}

From source file:net.sf.sessionAnalysis.SessionVisitorSessionLengthNanosStatistics.java

public void writeSessionsOverTime(final String outputDir) throws IOException {
    FileWriter fw = new FileWriter(
            outputDir + "/" + this.getClass().getSimpleName() + "-sessionLengthsNanoSeconds.csv");
    BufferedWriter writer = new BufferedWriter(fw);

    writer.write("lengthNanos");
    writer.newLine();/* ww  w .j a  v a  2s  .  c o m*/
    for (double l : this.computeLengthVector()) {
        writer.write(Double.toString(l));
        writer.newLine();
    }

    writer.close();
    fw.close();
}

From source file:org.openengsb.openengsbplugin.tools.OpenEngSBVersionResolver.java

private File createTmpFile(String content) throws IOException {
    File temp = File.createTempFile("metadata", ".xml");
    temp.deleteOnExit();//  w ww . j a  v a  2 s.  c om
    BufferedWriter out = new BufferedWriter(new FileWriter(temp));
    out.write(content);
    out.close();
    return temp;
}

From source file:com.aiblockchain.api.StringUtils.java

/**
 * Appends the given number of spaces to the given buffered writer.
 *
 * @param bufferedWriter the given buffered writer
 * @param indent the given number of spaces
 *///ww  w. j  a  v  a  2s  .c o  m
public static void indentSpaces(final BufferedWriter bufferedWriter, final int indent) {
    //Preconditions
    assert bufferedWriter != null : "bufferedWriter must not be null";
    assert indent >= 0 : "indent must not be negative";

    try {
        for (int i = 0; i < indent; i++) {
            bufferedWriter.write(' ');
        }
    } catch (IOException ex) {
    }
}