public class BufferUtils
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
BufferUtils.SizeLimitedOutputStream
An output stream that counts the number of bytes written to it and throws an
exception when the size exceeds a given limit.
|
private static class |
BufferUtils.SizeLimitExceededException
Exception used by SizeLimitedOutputStream if the size limit has been exceeded.
|
| Modifier and Type | Field and Description |
|---|---|
private static byte[] |
_cacheBuffer |
private static boolean |
_cacheBufferInUse |
private static java.nio.ByteBuffer |
_cacheByteBuffer |
private static boolean |
_cacheByteBufferInUse |
static int |
BUFFER_LEN |
(package private) static boolean |
ENABLE_BAAOS_OPT |
(package private) static boolean |
ENABLE_FILE_CHANNEL |
private static org.apache.commons.logging.Log |
log |
| Constructor and Description |
|---|
BufferUtils() |
| Modifier and Type | Method and Description |
|---|---|
static int |
doesDataHandlerExceedLimit(javax.activation.DataHandler dh,
int limit)
The method checks to see if attachment is eligble for optimization.
|
private static byte[] |
getTempBuffer() |
private static java.nio.ByteBuffer |
getTempByteBuffer() |
static long |
inputStream2BAAOutputStream(java.io.InputStream is,
BAAOutputStream baaos,
long limit)
inputStream2BAAOutputStream
|
static boolean |
inputStream2FileOutputStream(java.io.InputStream is,
java.io.FileOutputStream fos)
Opimized writing to FileOutputStream using a channel
|
static void |
inputStream2OutputStream(java.io.InputStream is,
java.io.OutputStream os)
Private utility to write the InputStream contents to the OutputStream.
|
static int |
inputStream2OutputStream(java.io.InputStream is,
java.io.OutputStream os,
int limit) |
private static void |
releaseTempBuffer(byte[] buffer) |
private static void |
releaseTempByteBuffer(java.nio.ByteBuffer buffer) |
private static final org.apache.commons.logging.Log log
public static final int BUFFER_LEN
static boolean ENABLE_FILE_CHANNEL
static boolean ENABLE_BAAOS_OPT
private static byte[] _cacheBuffer
private static boolean _cacheBufferInUse
private static java.nio.ByteBuffer _cacheByteBuffer
private static boolean _cacheByteBufferInUse
public static void inputStream2OutputStream(java.io.InputStream is,
java.io.OutputStream os)
throws java.io.IOException
is - os - java.io.IOExceptionpublic static int inputStream2OutputStream(java.io.InputStream is,
java.io.OutputStream os,
int limit)
throws java.io.IOException
is - InputStreamos - OutputStreamlimit - maximum number of bytes to readjava.io.IOExceptionpublic static boolean inputStream2FileOutputStream(java.io.InputStream is,
java.io.FileOutputStream fos)
throws java.io.IOException
is - fos - java.io.IOExceptionpublic static long inputStream2BAAOutputStream(java.io.InputStream is,
BAAOutputStream baaos,
long limit)
throws java.io.IOException
is - baaos - limit - java.io.IOExceptionpublic static int doesDataHandlerExceedLimit(javax.activation.DataHandler dh,
int limit)
dh - limit - java.io.IOExceptionprivate static byte[] getTempBuffer()
private static void releaseTempBuffer(byte[] buffer)
private static java.nio.ByteBuffer getTempByteBuffer()
private static void releaseTempByteBuffer(java.nio.ByteBuffer buffer)