public FileDeferredOutputStream(@Nonnull File backingFile, int bufferSize) throws FileNotFoundException { this.backingFile = backingFile; output = new NakedBufferedOutputStream(new FileOutputStream(backingFile), bufferSize); }
@Override public void writeTo(@Nonnull OutputStream dest) throws IOException { byte[] outBuf = output.getBuffer(); int count = output.getCount(); output.resetBuffer(); output.close(); // did we actually write something out to disk? if (count != writtenBytes) { InputStream fis = new FileInputStream(backingFile); ByteStreams.copy(fis, dest); backingFile.delete(); } dest.write(outBuf, 0, count); }
@Override public void close() throws IOException { output.close(); }
@Override public void flush() throws IOException { output.flush(); }
@Override public void flush() throws IOException { output.flush(); }
@Override public void close() throws IOException { output.close(); }
@Override public void flush() throws IOException { output.flush(); }
@Override public void write(int i) throws IOException { output.write(i); writtenBytes++; }
@Override public void close() throws IOException { output.close(); }
@Override public void write(byte[] bytes) throws IOException { output.write(bytes); writtenBytes += bytes.length; }
@Override public void write(byte[] bytes, int off, int len) throws IOException { output.write(bytes, off, len); writtenBytes += len; }
@Override public void write(byte[] bytes, int off, int len) throws IOException { output.write(bytes, off, len); writtenBytes += len; }
@Override public void write(byte[] bytes) throws IOException { output.write(bytes); writtenBytes += bytes.length; }
@Override public void write(int i) throws IOException { output.write(i); writtenBytes++; }
@Override public void write(byte[] bytes) throws IOException { output.write(bytes); writtenBytes += bytes.length; }
@Override public void write(int i) throws IOException { output.write(i); writtenBytes++; }
@Override public void write(byte[] bytes, int off, int len) throws IOException { output.write(bytes, off, len); writtenBytes += len; }
public FileDeferredOutputStream(@Nonnull File backingFile, int bufferSize) throws FileNotFoundException { this.backingFile = backingFile; output = new NakedBufferedOutputStream(new FileOutputStream(backingFile), bufferSize); }
@Override public void writeTo(@Nonnull OutputStream dest) throws IOException { byte[] outBuf = output.getBuffer(); int count = output.getCount(); output.resetBuffer(); output.close(); // did we actually write something out to disk? if (count != writtenBytes) { InputStream fis = new FileInputStream(backingFile); ByteStreams.copy(fis, dest); backingFile.delete(); } dest.write(outBuf, 0, count); }
public FileDeferredOutputStream(@Nonnull File backingFile, int bufferSize) throws FileNotFoundException { this.backingFile = backingFile; output = new NakedBufferedOutputStream(new FileOutputStream(backingFile), bufferSize); }