Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within I/O and Streams
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
I/O and Streams
writing file to OutputStream
sony rao
Greenhorn
Posts: 20
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi
is it possible to create and write a file into OutputStream without saving the file physically onto any drive. if so how?
thank you in advance
Rob Spoor
Sheriff
Posts: 22783
131
I like...
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Well you can't write (the contents of) a file to an OutputStream if that file does not exist, now can you?
Of course it is possible to copy the contents of any InputStream to any OutputStream without saving the results to a file first:
InputStream is; OutputStream os; // initialize byte[] buffer = new byte[4096]; // tweaking this number may increase performance int len; while ((len = is.read(buffer)) != -1) { os.write(buffer, 0, len); } os.flush(); is.close(); os.close();
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
Ulf Dittmer
Rancher
Posts: 43081
77
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What is the point of creating a file without writing it anywhere? If you want the data to be in memory instead of in a file, you can use a ByteArrayOutputStream.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
how to create ontology
How to encode image in parts?
Receiving a stream from a jsp
How to display Buffered Image object in jsp
I/O AGAIN
More...