Package nbbrd.io

Class BlockSizer

java.lang.Object
nbbrd.io.BlockSizer

public class BlockSizer extends Object
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 Details

  • Constructor Details

    • BlockSizer

      public BlockSizer()
  • Method Details

    • getBlockSize

      public long getBlockSize(@NonNull @NonNull Path file) throws IOException
      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

      public long getBlockSize(@NonNull @NonNull InputStream stream) throws IOException
      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

      public long getBlockSize(@NonNull @NonNull OutputStream stream) throws IOException
      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