File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes InputStream into byte array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "InputStream into byte array" Watch "InputStream into byte array" New topic
Author

InputStream into byte array

Dean Reedy
Ranch Hand

Joined: Sep 10, 2001
Posts: 89
I need to read a text file into a byte array. How could I do this.
For example I have a byte array called buffer, I have opened a InputStream "is" and I am reading it in one byte at a time. Now how do I append or add the int "c" into the byte array called "buffer"? Any better ideas would be great.
byte [] buffer;
int c;
while ( c = is.read() != -1 )) {
???
}
thanks,
Dean
 
GeeCON Prague 2014
 
subject: InputStream into byte array