java.lang.Object
org.sejda.io.CountingWritableByteChannel
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,WritableByteChannel
A
WritableByteChannel that keeps track of the number of written bytes- Author:
- Andrea Vacondio
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longcount()static CountingWritableByteChannelStatic factory method to create aCountingWritableByteChannelfrom an existingFile.static CountingWritableByteChannelfrom(OutputStream stream) Static factory method to create aCountingWritableByteChannelfrom an existingOutputStream.static CountingWritableByteChannelStatic factory method to create aCountingWritableByteChannelfrom an existing file path.static CountingWritableByteChannelfrom(WritableByteChannel channel) Static factory method to create aCountingWritableByteChannelfrom an existingWritableByteChannel.booleanisOpen()intwrite(ByteBuffer src)
-
Constructor Details
-
CountingWritableByteChannel
-
-
Method Details
-
count
public long count()- Returns:
- the number of written bytes
-
write
- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
isOpen
public boolean isOpen() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
from
Static factory method to create aCountingWritableByteChannelfrom an existingWritableByteChannel.- Parameters:
channel-- Returns:
- the newly created
CountingWritableByteChannel
-
from
Static factory method to create aCountingWritableByteChannelfrom an existingOutputStream.- Parameters:
stream-- Returns:
- the newly created
CountingWritableByteChannel
-
from
Static factory method to create aCountingWritableByteChannelfrom an existingFile. If the file already exists its content is purged.- Parameters:
file-- Returns:
- the newly created
CountingWritableByteChannel - Throws:
IOException- See Also:
-
from
Static factory method to create aCountingWritableByteChannelfrom an existing file path. If the file already exists its content is purged.- Parameters:
file-- Returns:
- the newly created
CountingWritableByteChannel - Throws:
IOException- See Also:
-