create file from byte array

OK, I have an array of bytes that I have retrieved from my database (byte[]).

How do I convert these bytes into a file?

Many thanks.
u9707118Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
lhankinsConnect With a Mentor Commented:
Something like this :

         byte [] myBytes = "sampledata".getBytes();

         FileOutputStream out = new FileOutputStream("outfile.txt");
         out.write(myBytes);
         out.close();
0
 
CEHJCommented:
If you want to create something you can read from without making a file, do

InputStream in = new ByteArrayInputStream(myBytes);
0
 
u9707118Author Commented:
Thanks,

Just what I wanted.  Sorry, took so long to give the points...didn't get a chance before I went on hols.

Cheers.
0
All Courses

From novice to tech pro — start learning today.