I am wondering if BufferedOutputStream offers any way to provide the count of bytes it has written. I am porting code from C# to Java. The code uses Stream.Position to obtain the count of written bytes.
Could anyone shed some light on this? This is not a huge deal because I can easily add a few lines of code to track the count. It would be nice if BufferedOutputStream already has the function.
For text there is a
LineNumberReader, but no counting the progress of anOutputStream. You can add that with a wrapper class, aFilterOutputStream.One could also think using a
MemoryMappedByteBuffer(a memory mapped file) for a better speed/memory behavior. Created from a RandomAccessFile or FileChannel.If all is too circumstantial, use the
Filesclass which has many utilities, likecopy. It usesPath- a generalisation of (disk I/O)File-, for files from the internet, files inside zip files, class path resources and so on.