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 make FileInputStream out of InputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "make FileInputStream out of InputStream" Watch "make FileInputStream out of InputStream" New topic
Author

make FileInputStream out of InputStream

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

No, it isn't.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
 
GeeCON Prague 2014
 
subject: make FileInputStream out of InputStream