?
Solved

create file from byte array

Posted on 2005-03-21
3
Medium Priority
?
2,777 Views
Last Modified: 2008-01-16
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.
0
Comment
Question by:u9707118
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Accepted Solution

by:
lhankins earned 1000 total points
ID: 13593969
Something like this :

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

         FileOutputStream out = new FileOutputStream("outfile.txt");
         out.write(myBytes);
         out.close();
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13594042
If you want to create something you can read from without making a file, do

InputStream in = new ByteArrayInputStream(myBytes);
0
 

Author Comment

by:u9707118
ID: 13647247
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question