private void writeLines(Iterator<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lineSeparator); try (Writer out = openBufferedStream()) { while (lines.hasNext()) { out.append(lines.next()).append(lineSeparator); } } }
/** * Writes the given lines of text to this sink with each line (including the last) terminated with * the given line separator. * * @throws IOException if an I/O error occurs while writing to this sink */ public void writeLines(Iterable<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lines); checkNotNull(lineSeparator); Closer closer = Closer.create(); try { Writer out = closer.register(openBufferedStream()); for (CharSequence line : lines) { out.append(line).append(lineSeparator); } out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330 } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
private void writeLines(Iterator<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lineSeparator); try (Writer out = openBufferedStream()) { while (lines.hasNext()) { out.append(lines.next()).append(lineSeparator); } } }
public void testOpenBufferedStream() throws IOException { Writer writer = sink.openBufferedStream(); try { writer.write(data); } finally { writer.close(); } assertContainsExpectedString(); }
public void writeToSink(CharSink sink) { try (Writer writer = sink.openBufferedStream()) { writer.append("some string"); } }
private void writeLines(Iterator<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lineSeparator); try (Writer out = openBufferedStream()) { while (lines.hasNext()) { out.append(lines.next()).append(lineSeparator); } } }
private void writeLines(Iterator<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lineSeparator); try (Writer out = openBufferedStream()) { while (lines.hasNext()) { out.append(lines.next()).append(lineSeparator); } } }
/** * Writes the given lines of text to this sink with each line (including the last) terminated with * the given line separator. * * @throws IOException if an I/O error occurs in the process of writing to this sink */ public void writeLines(Iterable<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lines); checkNotNull(lineSeparator); Closer closer = Closer.create(); try { BufferedWriter out = closer.register(openBufferedStream()); for (CharSequence line : lines) { out.append(line).append(lineSeparator); } } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
/** * Writes the given lines of text to this sink with each line (including the last) terminated with * the given line separator. * * @throws IOException if an I/O error occurs in the process of writing to this sink */ public void writeLines(Iterable<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lines); checkNotNull(lineSeparator); Closer closer = Closer.create(); try { Writer out = closer.register(openBufferedStream()); for (CharSequence line : lines) { out.append(line).append(lineSeparator); } out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330 } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
/** * Writes the given lines of text to this sink with each line (including the last) terminated with * the given line separator. * * @throws IOException if an I/O error occurs in the process of writing to this sink */ public void writeLines(Iterable<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lines); checkNotNull(lineSeparator); Closer closer = Closer.create(); try { Writer out = closer.register(openBufferedStream()); for (CharSequence line : lines) { out.append(line).append(lineSeparator); } out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330 } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
/** * Writes the given lines of text to this sink with each line (including the last) terminated with * the given line separator. * * @throws IOException if an I/O error occurs in the process of writing to this sink */ public void writeLines(Iterable<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lines); checkNotNull(lineSeparator); Closer closer = Closer.create(); try { Writer out = closer.register(openBufferedStream()); for (CharSequence line : lines) { out.append(line).append(lineSeparator); } out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330 } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
/** * Writes the given lines of text to this sink with each line (including the last) terminated with * the given line separator. * * @throws IOException if an I/O error occurs in the process of writing to this sink */ public void writeLines(Iterable<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lines); checkNotNull(lineSeparator); Closer closer = Closer.create(); try { Writer out = closer.register(openBufferedStream()); for (CharSequence line : lines) { out.append(line).append(lineSeparator); } out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330 } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
/** * Writes the given lines of text to this sink with each line (including the last) terminated with * the given line separator. * * @throws IOException if an I/O error occurs in the process of writing to this sink */ public void writeLines(Iterable<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lines); checkNotNull(lineSeparator); Closer closer = Closer.create(); try { Writer out = closer.register(openBufferedStream()); for (CharSequence line : lines) { out.append(line).append(lineSeparator); } out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330 } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
/** * Writes the given lines of text to this sink with each line (including the last) terminated with * the given line separator. * * @throws IOException if an I/O error occurs in the process of writing to this sink */ public void writeLines(Iterable<? extends CharSequence> lines, String lineSeparator) throws IOException { checkNotNull(lines); checkNotNull(lineSeparator); Closer closer = Closer.create(); try { Writer out = closer.register(openBufferedStream()); for (CharSequence line : lines) { out.append(line).append(lineSeparator); } out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330 } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
public void writeTable(CharSink sink) throws IOException { NumberFormat format = new DecimalFormat("0.0000"); try(Writer out = sink.openBufferedStream()) { out.append(Joiner.on(',').join(getDimensionNames())).append("\n"); for (int i = 0; i != getRowCount(); ++i) { for (int j = 0; j != getColumnCount(); ++j) { for (int d = 0; d != getDimensionCount(); ++d) { if(d > 0) { out.append(","); } double score = score(i, j, d); if(Double.isNaN(score)) { out.append("NA"); } else if(score == 0 || score == 1){ out.append(Integer.toString((int) score)); } else { out.append(format.format(score)); } } out.append('\n'); } } } } }
public void testOpenBufferedStream() throws IOException { Writer writer = sink.openBufferedStream(); try { writer.write(data); } finally { writer.close(); } assertContainsExpectedString(); }
charSink = Files.asCharSink(outputFile, Charsets.UTF_8); this.output = charSink.openBufferedStream(); } catch (IOException e) { throw new BuildException(e);
static public <V> void export(DiGraph<V> g, CharSink dest) throws IOException { final DOTExporterTemp<V, Edge<V>> exporter = new DOTExporterTemp<V, Edge<V>>(new IntegerNameProvider<V>(), new StringNameProvider<V>(), null); try (Writer writer = dest.openBufferedStream()) { exporter.export(writer, g.getGraph()); } }