• Post Reply Bookmark Topic Watch Topic
  • New Topic

hi  RSS feed

 
pavanasree vasireddy
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all

I am stuck up with a problem. I have an OutputStream object. I would like to write that data into a file.

Please help me


Thanks in advance



Pavana Sree V
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

have you checked the FileOutputStream class (API) ?

Something like:


or you could also have a look at the FileWriter class which you can use to write Strings (OutputStreams are 'characteter oriented'). In case you need to use a Writer with a OutputStream there is an OutputStreamWriter class that helps to 'connect' Writer and OutputStream.

i hope this is enough to get you going. If not then it might be best to post also the relevant parts from your code.

pascal
[ January 04, 2005: Message edited by: pascal betz ]
 
pavanasree vasireddy
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

thanks for the reply

I could not get it properly . I am copying the code below. I have data in the OutputStream object which i want to write OutputStream object to a file.


OutputStream os=MimeUtility.encode(fos,"base64");
BufferedOutputStream bos1 = new BufferedOutputStream(os);



Any help is very much appreciated.

Pavana Sree V
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need a FileOutputStream in there to send the output to a file. (I say "I think" because I don't see enough code there to tell if you've already added it or not.)

Good luck!
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pavanasree vasireddy:


OutputStream os=MimeUtility.encode(fos,"base64");
BufferedOutputStream bos1 = new BufferedOutputStream(os);


"fos" is a "FileOutputStream", yes? From the looks of this code, what's happening is that you create a FileOutputStream and hand it to the encode() method, and then you get an OutputStream back. You then call write() on the OutputStream (directly, or indirectly through a wrapper like BufferedOutputStream) and whatevent you wrote to the OutputStream ends up in the FileOutputStream's file, encoded.

Did you know that before? Do you understand now? Does this make you reconsider your question?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!