Convert a file content to a byte array.
680524May 5 2011 — edited May 6 2011Dear friends,
I have a file and I want to encode the content using org.apache.axis.encoding.Base64.encode(byte[] data, int off, int len, java.io.Writer writer) .
So I need to convert the content to byte array first. The idea comes to me first is to use the FileInputStream to read the content to the byte array. But is is a little complex since I need to think if the file is too big to read once, I need to use buffer and loop statement to handle it finally so that all the content can be read into a byte array.
My question is is there some APIs available to do that more easily?
Thanks,
Ricky