Package org.apache.orc.impl
Class IOUtils
java.lang.Object
org.apache.orc.impl.IOUtils
This is copied from commons-io project to cut the dependency
from old Hadoop.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
The maximum size of array to allocate, value being the same asHashtable
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
Returns a new byte array of sizeDEFAULT_BUFFER_SIZE
.static byte[]
byteArray
(int size) Returns a new byte array of the given size.static long
skip
(InputStream input, long toSkip) Skips bytes from an input byte stream.static void
skipFully
(InputStream input, long toSkip) Skips the requested number of bytes or fail if there are not enough left.
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
MAX_ARRAY_SIZE
public static final int MAX_ARRAY_SIZEThe maximum size of array to allocate, value being the same asHashtable
- See Also:
-
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
byteArray
public static byte[] byteArray()Returns a new byte array of sizeDEFAULT_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
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 skiptoSkip
- the number of bytes to skip- Throws:
IOException
- if there is a problem reading the fileIllegalArgumentException
- if toSkip is negativeEOFException
- if the number of bytes skipped was incorrect- Since:
- 2.0
- See Also:
-
skip
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 ofInputStream
.Note that the implementation uses
InputStream.read(byte[], int, int)
rather than delegating toInputStream.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 skiptoSkip
- number of bytes to skip.- Returns:
- number of bytes actually skipped.
- Throws:
IOException
- if there is a problem reading the fileIllegalArgumentException
- if toSkip is negative- Since:
- 2.0
- See Also:
-