Class IoUtils

java.lang.Object
org.apache.commons.crypto.utils.IoUtils

public final class IoUtils extends Object
General utility methods for working with IO.
  • Constructor Details

    • IoUtils

      private IoUtils()
      The private constructor of IoUtils.
  • Method Details

    • cleanup

      public static void cleanup(Closeable... closeables)
      Closes the Closeable objects and ignore any IOException or null pointers. Must only be used for cleanup in exception handlers.
      Parameters:
      closeables - the objects to close.
    • closeQuietly

      public static void closeQuietly(Closeable closeable)
      Closes the given Closeable quietly by ignoring IOException.
      Parameters:
      closeable - The resource to close.
      Since:
      1.1.0
    • readFully

      public static void readFully(Input in, long position, byte[] buffer, int offset, int length) throws IOException
      Does the readFully based on Input's positioned read. This does not change the current offset of the stream and is thread-safe.
      Parameters:
      in - the input source.
      position - the given position.
      buffer - the buffer to be read.
      offset - the start offset in array buffer.
      length - the maximum number of bytes to read.
      Throws:
      IOException - if an I/O error occurs.
    • readFully

      public static void readFully(InputStream in, byte[] buf, int off, int len) throws IOException
      Does the readFully based on the Input read.
      Parameters:
      in - the input stream of bytes.
      buf - the buffer to be read.
      off - the start offset in array buffer.
      len - the maximum number of bytes to read.
      Throws:
      IOException - if an I/O error occurs.