public static void writeDocument(final KAFDocument document, @Nullable final Path location) throws IOException { if (location == null) { System.out.write(document.toString().getBytes(Charsets.UTF_8)); } else { try (Writer writer = IO.utf8Writer(IO.buffer(IO.write(location.toString())))) { writer.write(document.toString()); } } }
@SuppressWarnings("unchecked") @Override public void handle(final BindingSet bindings) throws Throwable { if (this.writer == null) { this.writer = IO.utf8Writer(IO.buffer(IO.write(Query.this.file .getAbsolutePath()))); writerToClose.set(this.writer); this.variables = stream.getProperty("variables", List.class); for (int i = 0; i < this.variables.size(); ++i) { this.writer.write(i > 0 ? "\t?" : "?"); this.writer.write(this.variables.get(i)); } this.writer.write("\n"); } if (bindings != null) { this.writer.write(TestUtil.encode(this.variables, bindings)); this.writer.write("\n"); tracker.increment(); } }
logger.info("Writing file " + outputFile); Files.createParentDirs(outputFile); try (Writer w = IO.utf8Writer(IO.buffer(IO.write(outputFile.getAbsolutePath())))) { w.write(naf);
public void writeTo(final String location) throws IOException { try (Writer writer = IO.utf8Writer(IO.buffer(IO.write(location)))) { writeTo(writer); } }
.write(this.outputFile.getAbsolutePath())));
try (Writer writer = IO.utf8Writer(IO.buffer(IO.write(file.getAbsolutePath())))) {
logger.info("Writing empty file " + outputFile); Files.createParentDirs(outputFile); try (Writer w = IO.utf8Writer(IO.buffer(IO.write(outputFile.getAbsolutePath())))) { w.write(document.toString());
final Model model = this.generator.generate(document, null); Files.createParentDirs(outputFile); try (Writer writer = IO.utf8Writer(IO.write(outputFile.getAbsolutePath()))) { renderer.renderAll(writer, document, model, this.template, null);
try (Writer writer = IO.utf8Writer(IO.buffer(IO.write(output.getAbsolutePath())))) { for (int childNum = 0; childNum < sortedIDs.size(); ++childNum) { final String childID = sortedIDs.get(childNum);
private static void writeBinary(final Stream<Record> records, final File file) throws IOException { final String base = file.getAbsolutePath(); final Dictionary<URI> dictionary = Dictionary.createLocalDictionary(URI.class, new File( base + ".dict")); final Serializer serializer = new Serializer(false, dictionary, Statements.VALUE_FACTORY); final CountingOutputStream stream = new CountingOutputStream(IO.write(base + ".gz")); try { records.toHandler(new Handler<Record>() { private int records = 0; @Override public void handle(final Record record) throws Throwable { if (record == null || this.records > 0 && this.records % 1000 == 0) { LOGGER.info("{} records, {} bytes processed ({} bytes/record)", this.records, stream.getCount(), stream.getCount() / this.records); } if (record != null) { serializer.toStream(stream, record); ++this.records; } } }); } finally { IO.closeQuietly(records); IO.closeQuietly(stream); } }
final OutputStream stream = IO.write(file.getAbsolutePath());