Package nbbrd.io
Class BlockSizer
java.lang.Object
nbbrd.io.BlockSizer
System-wide utility that gets the number of bytes per block from several byte sources.
May be overridden to deal with new JDK APIs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longstatic final AtomicReference<BlockSizer> static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetBlockSize(@NonNull InputStream stream) Returns the number of bytes per block in the input stream implementation.longgetBlockSize(@NonNull OutputStream stream) Returns the number of bytes per block in the output stream implementation.longgetBlockSize(@NonNull Path file) Returns the number of bytes per block in the file store of this file.
-
Field Details
-
INSTANCE
-
DEFAULT_BLOCK_BUFFER_SIZE
public static final long DEFAULT_BLOCK_BUFFER_SIZE- See Also:
-
DEFAULT_BUFFER_OUTPUT_STREAM_SIZE
public static final long DEFAULT_BUFFER_OUTPUT_STREAM_SIZE- See Also:
-
UNKNOWN_SIZE
public static final long UNKNOWN_SIZE- See Also:
-
-
Constructor Details
-
BlockSizer
public BlockSizer()
-
-
Method Details
-
getBlockSize
Returns the number of bytes per block in the file store of this file.- Parameters:
file- a non-null file as byte source- Returns:
- a positive value representing the block size in bytes if available, -1 otherwise
- Throws:
IOException- if an I/O error occurs- See Also:
-
getBlockSize
Returns the number of bytes per block in the input stream implementation.- Parameters:
stream- a non-null input stream as byte source- Returns:
- a positive value representing the block size in bytes if available, -1 otherwise
- Throws:
IOException- if an I/O error occurs
-
getBlockSize
Returns the number of bytes per block in the output stream implementation.- Parameters:
stream- a non-null output stream as byte source- Returns:
- a positive value representing the block size in bytes if available, -1 otherwise
- Throws:
IOException- if an I/O error occurs
-