| Author |
byte[] to file
|
Dave Comeau
Greenhorn
Joined: Jun 14, 2002
Posts: 27
|
|
Hi, I have a byte[] that contains binary image data (for pngs and gifs). I can't figure out how to write this data to a file. Can anyone give me an overview of what I need to do? Thanks!
|
 |
kishor rao
Ranch Hand
Joined: Dec 10, 2002
Posts: 35
|
|
FileOutputStream f = new FileOutputStream("pic.gif"); for(int i = 0; i < <size of ur byte array>; i++) f.write(<ur byte array name>[i]); f.close(); i think this should do it.
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
No need for a loop - just spit out the whole array at once: The BufferedOutputStream is optional, but a good idea in general for efficiency. [ January 30, 2003: Message edited by: Jim Yingst ]
|
"I'm not back." - Bill Harding, Twister
|
 |
Dave Comeau
Greenhorn
Joined: Jun 14, 2002
Posts: 27
|
|
|
Worked perfect. Thanks so much!
|
 |
 |
|
|
subject: byte[] to file
|
|
|