/** * Convenience method that has the same effect as calling {@link #getByteArray(int)} with * a length equal to {@link #getDefaultBufferSize()}. * * @return a byte array with a length of {@link #getDefaultBufferSize()} */ public static synchronized byte[] getByteArray() { return getByteArray(getDefaultBufferSize()); }
/** * This method is a shorthand for {@link #fillWithConstant(java.io.OutputStream, byte, long, int)} called with a * {@link BufferPool#getDefaultBufferSize default buffer size}. * * @param out the OutputStream to write to * @param value the byte constant to write len times * @param len number of bytes to write * @throws java.io.IOException if an error occurred while writing */ public static void fillWithConstant(OutputStream out, byte value, long len) throws IOException { fillWithConstant(out, value, len, BufferPool.getDefaultBufferSize()); }
/** * Convenience method that has the same effect as calling {@link #getCharArray(int)} with * a length equal to {@link #getDefaultBufferSize()}. * * @return a char array with a length of {@link #getDefaultBufferSize()} */ public static synchronized char[] getCharArray() { return getCharArray(getDefaultBufferSize()); }
/** * This method is a shorthand for {@link #copyStream(java.io.InputStream, java.io.OutputStream, int)} called with a * {@link BufferPool#getDefaultBufferSize() default buffer size}. * * @param in the InputStream to read from * @param out the OutputStream to write to * @return the number of bytes that were copied * @throws FileTransferException if something went wrong while reading from or writing to one of the provided streams */ public static long copyStream(InputStream in, OutputStream out) throws FileTransferException { return copyStream(in, out, BufferPool.getDefaultBufferSize()); }
/** * This method is a shorthand for {@link #readUntilEOF(java.io.InputStream, int)} called with a * {@link BufferPool#getDefaultBufferSize default buffer size}. * * @param in the InputStream to read * @throws IOException if an I/O error occurs */ public static void readUntilEOF(InputStream in) throws IOException { readUntilEOF(in, BufferPool.getDefaultBufferSize()); }
/** * Convenience method that has the same effect as calling {@link #getByteBuffer(int)} with * a buffer capacity of {@link #getDefaultBufferSize()}. * * @return a ByteBuffer with a capacity equal to {@link #getDefaultBufferSize()} */ public static synchronized ByteBuffer getByteBuffer() { return getByteBuffer(getDefaultBufferSize()); }
/** * Convenience method that has the same effect as calling {@link #getCharBuffer(int)} with * a buffer capacity of {@link #getDefaultBufferSize()}. * * @return a CharBuffer with a capacity equal to {@link #getDefaultBufferSize()} */ public static synchronized CharBuffer getCharBuffer() { return getCharBuffer(getDefaultBufferSize()); }
/** * Convenience method that has the same effect as calling {@link #getBuffer(com.mucommander.commons.io.BufferPool.BufferFactory, int)} * with a size equal to {@link #getDefaultBufferSize()}. * * @param factory BufferFactory used to identify the target buffer class and create a new buffer (if necessary) * @return a buffer with a size equal to {@link #getDefaultBufferSize()} */ public static synchronized Object getBuffer(BufferFactory factory) { return getBuffer(factory, getDefaultBufferSize()); }
/** * This method is a shorthand for {@link #transcode(java.io.InputStream, String, java.io.OutputStream, String, int)} * called with a {@link BufferPool#getDefaultBufferSize() default buffer size}. * * @param in the InputStream to read from * @param inCharset the source charset * @param out the OutputStream to write to * @param outCharset the destination charset * @return the number of bytes that were transcoded * @throws FileTransferException if something went wrong while reading from or writing to one of the provided streams * @throws UnsupportedEncodingException if any of the two charsets are not supported by the JVM */ public static long transcode(InputStream in, String inCharset, OutputStream out, String outCharset) throws FileTransferException, UnsupportedEncodingException { return transcode(in, inCharset, out, outCharset, BufferPool.getDefaultBufferSize()); }
/** * This method is a shorthand for {@link #copyChunk(RandomAccessInputStream, RandomAccessOutputStream, long, long, long, int)} * called with a {@link BufferPool#getDefaultBufferSize default buffer size}. * * @param rais the source stream * @param raos the destination stream * @param srcOffset offset to the beginning of the chunk in the source stream * @param destOffset offset to the beginning of the chunk in the destination stream * @param length number of bytes to copy * @throws java.io.IOException if an error occurred while copying data */ public static void copyChunk(RandomAccessInputStream rais, RandomAccessOutputStream raos, long srcOffset, long destOffset, long length) throws IOException { copyChunk(rais, raos, srcOffset, destOffset, length, BufferPool.getDefaultBufferSize()); }
long written = StreamUtils.copyStream(origFileStream, out, BufferPool.getDefaultBufferSize(), partSize); sizeLeft -= written; } catch (FileTransferException e) {
assert BufferPool.INITIAL_DEFAULT_BUFFER_SIZE == BufferPool.getDefaultBufferSize(); assertBufferSize(BufferPool.getBuffer(factory), factory, BufferPool.INITIAL_DEFAULT_BUFFER_SIZE); assert TEST_BUFFER_SIZE_1 == BufferPool.getDefaultBufferSize(); assertBufferSize(BufferPool.getBuffer(factory), factory, TEST_BUFFER_SIZE_1);