public static byte[] copyToByteArray(InputStream in) throws IOException {
  ByteArrayOutputStream out=new ByteArrayOutputStream(BUFFER_SIZE);
  copy(in,out);
  return out.toByteArray();
}

public static byte [ ] copyToByteArray ( InputStream in ) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream ( BUFFER_SIZE ) ; copy ( in , out ) ; return out . toByteArray ( ) ; }
copy the contents of the given inputstream into a new byte array . closes the stream when done .
