The moose likes Beginning Java and the fly likes InputStream to fileReader Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 16483
    
    2

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: 16483
    
    2

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: 16483
    
    2

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: InputStream to fileReader
 
Similar Threads
How to check if HttpURLConnection exists using the object, which was open before
How to read Franch from ResourceBundle
How to get a String from an InputStream
How to display content of a url by using httpurlconnection?
Searching google images from java code