Class IOUtils

java.lang.Object
org.apache.orc.impl.IOUtils

public final class IOUtils extends Object
This is copied from commons-io project to cut the dependency from old Hadoop.
  • Field Details

    • DEFAULT_BUFFER_SIZE

      public static final int DEFAULT_BUFFER_SIZE
      See Also:
    • MAX_ARRAY_SIZE

      public static final int MAX_ARRAY_SIZE
      The maximum size of array to allocate, value being the same as Hashtable
      See Also:
  • Constructor Details

    • IOUtils

      public IOUtils()
  • Method Details

    • byteArray

      public static byte[] byteArray()
      Returns a new byte array of size DEFAULT_BUFFER_SIZE.
      Returns:
      a new byte array of size DEFAULT_BUFFER_SIZE.
      Since:
      2.9.0
    • byteArray

      public static byte[] byteArray(int size)
      Returns a new byte array of the given size. TODO Consider guarding or warning against large allocations...
      Parameters:
      size - array size.
      Returns:
      a new byte array of the given size.
      Since:
      2.9.0
    • skipFully

      public static void skipFully(InputStream input, long toSkip) throws IOException
      Skips the requested number of bytes or fail if there are not enough left.

      This allows for the possibility that InputStream.skip(long) may not skip as many bytes as requested (most likely because of reaching EOF).

      Note that the implementation uses skip(InputStream, long). This means that the method may be considerably less efficient than using the actual skip implementation, this is done to guarantee that the correct number of characters are skipped.

      Parameters:
      input - stream to skip
      toSkip - the number of bytes to skip
      Throws:
      IOException - if there is a problem reading the file
      IllegalArgumentException - if toSkip is negative
      EOFException - if the number of bytes skipped was incorrect
      Since:
      2.0
      See Also:
    • skip

      public static long skip(InputStream input, long toSkip) throws IOException
      Skips bytes from an input byte stream. This implementation guarantees that it will read as many bytes as possible before giving up; this may not always be the case for skip() implementations in subclasses of InputStream.

      Note that the implementation uses InputStream.read(byte[], int, int) rather than delegating to InputStream.skip(long). This means that the method may be considerably less efficient than using the actual skip implementation, this is done to guarantee that the correct number of bytes are skipped.

      Parameters:
      input - byte stream to skip
      toSkip - number of bytes to skip.
      Returns:
      number of bytes actually skipped.
      Throws:
      IOException - if there is a problem reading the file
      IllegalArgumentException - if toSkip is negative
      Since:
      2.0
      See Also: