public void testOpenBufferedStream() throws IOException { OutputStream out = sink.openBufferedStream(); try { ByteStreams.copy(new ByteArrayInputStream(data), out); } finally { out.close(); } assertContainsExpectedBytes(); }
public static <T> void writeTo(T model, File outputFile) throws IOException { ByteSink sink = Files.asByteSink(outputFile); try (ObjectOutputStream oos = new ObjectOutputStream(sink.openBufferedStream())) { oos.writeObject(model); } }
/** * Save an object to file. * * @param object the object * @throws java.io.IOException on save error */ public static void commit(@NonNull Object object) throws IOException { ByteSink sink; synchronized (bound) { sink = bound.get(object); if (sink == null) { throw new IOException("Cannot persist unbound object: " + object); } } Closer closer = Closer.create(); try { OutputStream os = closer.register(sink.openBufferedStream()); mapper.writeValue(os, object); } finally { closer.close(); } }
public void writeTo(@Nonnull File file) throws IOException { ByteSink sink = Files.asByteSink(file); OutputStream out = sink.openBufferedStream(); try { writeTo(out); } finally { out.close(); } }
appendStream = asByteSink(appendTo, APPEND).openBufferedStream();
appendStream = asByteSink(appendTo, APPEND).openBufferedStream();
appendStream = asByteSink(appendTo, APPEND).openBufferedStream();
public void testOpenBufferedStream() throws IOException { OutputStream out = sink.openBufferedStream(); try { ByteStreams.copy(new ByteArrayInputStream(data), out); } finally { out.close(); } assertContainsExpectedBytes(); }
/** * Method description * * * @param adminClient * @param repository * @param target * * @throws IOException * @throws SVNException */ private static void dump(SVNAdminClient adminClient, File repository, ByteSink target) throws SVNException, IOException { OutputStream outputStream = null; try { outputStream = target.openBufferedStream(); adminClient.doDump(repository, outputStream, SVNRevision.create(-1l), SVNRevision.HEAD, false, false); } finally { Closeables.close(outputStream, true); } }
ByteStreams.copy(in, Files.asByteSink(file).openBufferedStream()); } else { throw new FileNotFoundException("could not write to file "+path+"; it does not exist or is not writable");
ByteStreams.copy(in, Files.asByteSink(file).openBufferedStream()); } else { throw new FileNotFoundException("could not write to file "+path+"; it does not exist or is not writable");