src/main/java/org/jboss/util/stream/Streams.java
/**
    * Copy a limited number of bytes from the input stream to the 
    * output stream.
    *
    * @param input   Stream to read bytes from.
    * @param output  Stream to write bytes to.
    * @param size    The size of the buffer to use while copying.
    * @param length  The maximum number of bytes to copy.
    * @return        The total number of bytes copied.
    *
    * @throws IOException  Failed to copy bytes.
    */
Copy a limited number of bytes from the input stream to the
output stream.

@param input   Stream to read bytes from.
@param output  Stream to write bytes to.
@param size    The size of the buffer to use while copying.
@param length  The maximum number of bytes to copy.
@return        The total number of bytes copied.

@throws IOException  Failed to copy bytes.
Copy a limited number of bytes from the input stream to the output stream . @param input Stream to read bytes from . @param output Stream to write bytes to . @param size The size of the buffer to use while copying . @param length The maximum number of bytes to copy . @return The total number of bytes copied . @throws IOException Failed to copy bytes .
public static long copySome(final InputStream input, 
                               final OutputStream output, 
                               final int size,
                               final long length)
      throws IOException
   {
      return copySome(input, output, new byte[size], length);
   }
public static long copySome ( final InputStream input , final OutputStream output , final int size , final long length ) throws IOException { return copySome ( input , output , new byte [ size ] , length ) ; }
Copy a limited number of bytes from the input stream to the
 output stream.
Copy a limited number of bytes from the input stream to the output stream .