Package com.helger.io.stream
Class CountingFileOutputStream
java.lang.Object
java.io.OutputStream
java.io.FileOutputStream
com.helger.io.stream.CountingFileOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
A special
FileOutputStream sub class that keeps track of all written
bytes for the statistics handler.- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.helger.base.io.EAppendBy default append is enabled -
Constructor Summary
ConstructorsConstructorDescriptionCountingFileOutputStream(@NonNull File aFile) Constructor using the default append mode.CountingFileOutputStream(@NonNull File aFile, @NonNull com.helger.base.io.EAppend eAppend) Constructor with explicit append mode.CountingFileOutputStream(@NonNull String sFilename) Constructor using the default append mode.CountingFileOutputStream(@NonNull String sFilename, @NonNull com.helger.base.io.EAppend eAppend) Constructor with explicit append mode. -
Method Summary
Methods inherited from class java.io.FileOutputStream
close, getChannel, getFDMethods inherited from class java.io.OutputStream
flush, nullOutputStream
-
Field Details
-
DEFAULT_APPEND
public static final com.helger.base.io.EAppend DEFAULT_APPENDBy default append is enabled
-
-
Constructor Details
-
CountingFileOutputStream
Constructor using the default append mode.- Parameters:
aFile- The file to write to. May not benull.- Throws:
FileNotFoundException- If the file cannot be opened for writing.
-
CountingFileOutputStream
public CountingFileOutputStream(@NonNull File aFile, @NonNull com.helger.base.io.EAppend eAppend) throws FileNotFoundException Constructor with explicit append mode.- Parameters:
aFile- The file to write to. May not benull.eAppend- Appending mode. May not benull.- Throws:
FileNotFoundException- If the file cannot be opened for writing.
-
CountingFileOutputStream
Constructor using the default append mode.- Parameters:
sFilename- The filename to write to. May not benull.- Throws:
FileNotFoundException- If the file cannot be opened for writing.
-
CountingFileOutputStream
public CountingFileOutputStream(@NonNull String sFilename, @NonNull com.helger.base.io.EAppend eAppend) throws FileNotFoundException Constructor with explicit append mode.- Parameters:
sFilename- The filename to write to. May not benull.eAppend- Appending mode. May not benull.- Throws:
FileNotFoundException- If the file cannot be opened for writing.
-
-
Method Details
-
write
- Overrides:
writein classFileOutputStream- Throws:
IOException
-
write
- Overrides:
writein classFileOutputStream- Throws:
IOException
-
write
- Overrides:
writein classFileOutputStream- Throws:
IOException
-
getBytesWritten
@Nonnegative public long getBytesWritten()- Returns:
- The number of bytes written so far. Always ≥ 0.
-
toString
-