aspose file tools
The moose likes Beginning Java and the fly likes make FileInputStream out of InputStream 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 "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: 16483
    
    2

No, it isn't.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: make FileInputStream out of InputStream
 
Similar Threads
different betwean InputStream and FileInputStream
How to create a ResourceBundle from a file name (not a base name)
File Descriptor
TEMP file question
Reading an Image from Local drive and store to ByteArray