Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InputStream to fileReader

 
asit dhal
Greenhorn
Posts: 13
C++ Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Paul Clapham
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
C++ Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Paul

please help me out.
 
Paul Clapham
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
C++ Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic