Example usage for java.io BufferedWriter newLine

List of usage examples for java.io BufferedWriter newLine

Introduction

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

Prototype

public void newLine() throws IOException 

Source Link

Document

Writes a line separator.

Usage

From source file:com.smartitengineering.events.async.api.impl.hub.FileSystemUriStorer.java

@Override
public final void storeNextUri(String uri) {
    try {//from w  w  w  . j a  va 2s  .co  m
        writingInProgressMutex.acquire();
        logger.info("New URI being stored");
        if (logger.isDebugEnabled()) {
            logger.debug("URI being stored is " + uri);
        }
        BufferedWriter writer = new BufferedWriter(new FileWriter(uriStorage, false));
        writer.write(uri);
        writer.newLine();
        writer.flush();
        writer.close();
        setNextUri(uri);
    } catch (Exception ex) {
        logger.error("Could not write to file!", ex);
        throw new RuntimeException(ex);
    } finally {
        writingInProgressMutex.release();
    }
}

From source file:finalproject.FileIO.java

/**
 * Prints the date, data, and the notes to a file for later use
 * @param date//from   w  w w  . ja  va2  s.c o  m
 * @param data
 * @param notes 
 */
public void outputToFile(String date, String[][] data, String notes) {
    //File f = new File("Resources/Data/" + date + ".txt");
    // For "commercial" use
    //File f = new File("C:\\Program Files\\BGDataAnalysis\\Data\\" + date + ".txt");
    File f = new File("C:\\BGDataAnalysis\\Data\\" + date + ".txt");

    try {
        BufferedWriter wrtr = new BufferedWriter(new FileWriter(f));

        wrtr.write(date);
        wrtr.newLine();
        wrtr.write(notes);
        wrtr.newLine();

        for (int i = 0; i < 24; i++) {
            if (data[i][1] != null) {
                wrtr.write(data[i][0] + "%" + data[i][1]);
                wrtr.newLine();
            }

        }

        wrtr.close();
    } catch (Exception ex) {
        System.out.println("Output Error!");
        System.out.println(ex.getMessage());
    }
}

From source file:es.ua.dlsi.patch.translation.LocalApertiumTranslator.java

public Set<String> getTranslation(final String input) {

    Set<String> output = new HashSet<>();
    String finalline = "";
    // pull from the map if already there

    try {/* ww w. j a  v a 2s.  co m*/
        String[] command = { "apertium", "-u", langCmd };
        ProcessBuilder probuilder = new ProcessBuilder(command);

        Process process = probuilder.start();
        OutputStream stdin = process.getOutputStream();
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin));
        writer.write(input);
        writer.newLine();
        writer.flush();
        writer.close();

        InputStream is = process.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line;
        while ((line = br.readLine()) != null) {
            finalline += line;
        }
        br.close();

    } catch (Exception e) {
        e.printStackTrace(System.err);
        System.exit(-1);
    }
    output.add(finalline);
    return output;
}

From source file:org.apache.geode.management.internal.cli.util.LogExporter.java

private void writeLine(String line, BufferedWriter writer) {
    try {/*from ww w  .j  a va  2s.  com*/
        writer.write(line);
        writer.newLine();
    } catch (IOException e) {
        throw new RuntimeException("Unable to write to log file", e);
    }
}

From source file:com.iyonger.apm.web.service.MonitorCollectorPlugin.java

@Override
public void sampling(ISingleConsole singleConsole, PerfTest perfTest, IPerfTestService perfTestService,
        ImmutableStatisticsSet intervalStatistics, ImmutableStatisticsSet cumulativeStatistics) {
    for (Map.Entry<MonitorClientService, BufferedWriter> each : clientMap.entrySet()) {
        try {/*from www  .  ja va  2  s  . c o  m*/
            SystemInfo currentInfo = each.getKey().getSystemInfo();
            BufferedWriter bw = each.getValue();
            bw.write(currentInfo.toRecordString());
            bw.newLine();
        } catch (IOException e) {
            LOGGER.error("Error while saving file :" + e.getMessage());
        }
    }
}

From source file:playground.johannes.socialnets.GraphStatistics.java

static public Histogram createDegreeHistogram(Graph g, int min, int max, int ignoreWave) {
    Set<Vertex> vertices = new HashSet<Vertex>();
    for (Object o : g.getVertices()) {
        if (((Vertex) o).getUserDatum(UserDataKeys.ANONYMOUS_KEY) == null)
            vertices.add((Vertex) o);//from   ww  w.j a va2 s . c om
    }

    DoubleArrayList values = new DoubleArrayList(vertices.size());
    DoubleArrayList weights = new DoubleArrayList(vertices.size());

    try {
        BufferedWriter writer = IOUtils.getBufferedWriter(outputDir + ignoreWave + ".weights.txt");

        for (Vertex v : vertices) {
            int k = v.degree();
            values.add(k);
            writer.write(String.valueOf(k));
            writer.write("\t");
            Integer wave = (Integer) v.getUserDatum(UserDataKeys.SAMPLED_KEY);
            double w = 1;
            if (wave == null || k == 0)
                weights.add(1);
            else {
                //            w = 1 / (1 - Math.pow((1 - fracVertices),k));
                w = 1;// / (Double)v.getUserDatum(UserDataKeys.SAMPLE_PROBA_KEY);
                weights.add(w);
            }
            writer.write(String.valueOf(w));
            writer.newLine();
            writer.flush();
        }
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (min < 0 && max < 0) {
        DoubleArrayList copy = values.copy();
        copy.sort();
        min = (int) copy.get(0);
        max = (int) copy.get(values.size() - 1);
    }

    Histogram hist = new Histogram(1.0, 0, max);
    for (int i = 0; i < values.size(); i++) {
        hist.add(values.get(i), weights.get(i));
    }
    System.out.println("Gamma exponent is estimated to " + estimatePowerLawExponent(values));

    return hist;
}

From source file:net.estinet.gFeatures.Feature.gHub.config.gHubConfig.java

public void setup() {
    Config c = new Config();
    c.createDirectory("plugins/gFeatures/gHub", "Created gHub directory!");
    c.createFile("plugins/gFeatures/gHub/Config.yml", "Created gHub config!");
    File f = new File("plugins/gFeatures/gHub/spawn.txt");
    if (!f.exists()) {
        c.createFile("plugins/gFeatures/gHub/spawn.txt", "Created spawn location!");
        BufferedWriter output;
        try {/*w ww . j a va  2s .  co  m*/
            output = new BufferedWriter(new FileWriter(f, true));
            output.write("world");
            output.newLine();
            output.write("0");
            output.newLine();
            output.write("0");
            output.newLine();
            output.write("0");
            output.newLine();
            output.write("0");
            output.newLine();
            output.write("0");
            output.close();
        } catch (Exception e1) {
            Bukkit.getLogger().info("UHOH");
            e1.printStackTrace();
        }
    }
}

From source file:com.pieframework.runtime.operators.azure.RemoteDesktopOperator.java

private String generateConnectionFile(Role role, String instanceId, String slot) {
    String rdpDirString = ModelStore.getCurrentModel().getConfiguration().getTmp() + "azure"
            + File.separatorChar + "rdp";
    String connectionFileName = role.getParent().getId() + "-" + slot + "-" + role.getId() + "_IN_" + instanceId
            + ".rdp";
    File connectionFile = new File(rdpDirString + File.separatorChar + connectionFileName);
    File rdpDir = new File(rdpDirString);
    AzureHostedService ahs = (AzureHostedService) role.getParent().getResources().get("hostedService");
    AzureRdp ardp = (AzureRdp) role.getResources().get("rdpAccount");
    String username = ardp.getRdpUsername();
    String fqdn = AzureUtils.getHostedServiceFQDN(ahs.getUrlPrefix());

    try {/*ww w .j ava  2 s. c o m*/
        if (!rdpDir.exists()) {
            rdpDir.mkdirs();
        }

        BufferedWriter out = new BufferedWriter(new FileWriter(connectionFile.getPath()));
        out.write("full address:s:" + fqdn);
        out.newLine();
        out.write("username:s:" + username);
        out.newLine();
        out.write("LoadBalanceInfo:s:Cookie: mstshash=" + role.getId() + "#" + role.getId() + "_IN_"
                + instanceId + "#Microsoft.WindowsAzure.Plugins.RemoteAccess.Rdp");
        out.close();

    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return connectionFile.getPath();
}

From source file:eu.abc4trust.cryptoEngine.uprove.util.UProveLauncher.java

public int stop() {
    // System.out.println("UProveLauncher.stop instance : " + this + " : " + launchName + " - port : " + launchPort + " - is stopped == " + stopped + " - process : " + this.uproveProcess);
    if (this.uproveProcess != null) {
        try {/* ww w.j  a  v a  2s  .  c  om*/
            OutputStream outputStream = this.uproveProcess.getOutputStream();
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
            BufferedWriter out = new BufferedWriter(outputStreamWriter);
            out.newLine();
            out.flush();
            int exitCode = -1;
            boolean done = false;
            while (!done) {
                try {
                    exitCode = this.uproveProcess.exitValue();
                    done = true;
                    break;
                } catch (IllegalThreadStateException ex) {
                    // System.out.println("process not terminated");
                    this.waitFor(1);
                }
            }
            this.debugOutputCollector.stop();
            this.debugOutput.interrupt();
            this.uproveProcess = null;
            return exitCode;
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
    if (this.startCalled) {
        return Integer.MIN_VALUE;
    } else {
        return 0;
    }
}

From source file:net.stuxcrystal.simpledev.configuration.parser.generators.xml.CommentAwareDumper.java

/**
 * Dumps the content of a node.//from  w  ww  .j ava 2  s  . co m
 *
 * @param writer   The writer to write the content into.
 * @param node     The node to dump.
 * @param indent   The indent we should add in each line.
 * @throws java.io.IOException If an I/O-Operation fails.
 */
private void dump(BufferedWriter writer, Node<?> node, int indent) throws IOException {
    if (node.hasChildren()) {
        writer.newLine();
        for (Node<?> child : ((Node<Node<?>[]>) node).getData()) {
            this.dumpComment(writer, child, indent);
            this.dumpNode(writer, child, indent);
        }
        this.writeIndent(writer, indent - 2);

    } else {
        this.dumpScalar(writer, node);
    }
}