File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes InputStream to fileReader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "InputStream to fileReader" Watch "InputStream to fileReader" New topic
Author

InputStream to fileReader

asit dhal
Greenhorn

Joined: May 05, 2009
Posts: 13

just go through the following code




here the problem is at the line
reader = new FileReader(connection.getInputStream());


how can I convert InputStream to fileReader ?


http://kodeyard.blogspot.com/
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You can't. But why do you think you need a FileReader, anyway? Can't you use some other kind of Reader?
asit dhal
Greenhorn

Joined: May 05, 2009
Posts: 13

@Paul

please help me out.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

asit dhal wrote:@Paul

please help me out.


In what way? I asked you a question. That was intended to help you out. You can ignore it if you aren't interested in any help.
asit dhal
Greenhorn

Joined: May 05, 2009
Posts: 13

@Paul

Sorry, I didn't read your question properly.

I have a utility class which takes FileReader object as a parameter. I can't modify that.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

No competent writer of utility classes would write something which accepted a FileReader, when accepting a Reader would be much more user-friendly. So in my opinion it should really be changed.

But I'm sure you are right, you won't have the power to get it changed, no matter how badly it was originally written. In the meantime your workaround is to read the data from that InputStream and write it to a file on the local disk. Then get a FileReader from that file once you have finished that step.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: InputStream to fileReader
 
Similar Threads
Searching google images from java code
How to read Franch from ResourceBundle
How to check if HttpURLConnection exists using the object, which was open before
How to get a String from an InputStream
How to display content of a url by using httpurlconnection?