• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

make FileInputStream out of InputStream

 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to make FileInputStream out of InputStream? If so, could someone please point me to some code examples?
Thanks a lot.
 
Paul Clapham
Sheriff
Posts: 21117
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it isn't.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you could read everything from the original InputStream. write it to a file, and then open a new FileInputStream to read the file you just wrote. In general that sounds rather silly and inefficient - why do you need a FileInputStream as opposed to an InputStream? But perhaps it might be necessary in some case.

It's also possible to create your own FileInputStream class which overrides all the regular FileInputStream methods and replaces them with methods that read from the other InputStream instead. This is probably a horrible, ugly idea. But it's possible.

I think that in all likelihood, you need to examine why you need a FileInputStream here. There's probably going to be a better way to accomplish what you're trying to do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic