Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retrieve a file from a fileinputstream

 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to retrieve a file from a fileinputstream
:roll:
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not that I see, but you can get the FileChannel from the stream, find the size of the file, and construct a new one from the data.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends what you mean by "retrieve the file". You can certainly read the contents of the file. But if you want to know the name and location of a file, there doesn't seem to be any way to do that. If you really need to find the file name, and have no other way to do this, I suppose you could read in the contents, and then search the file system for a file with the same contents. (Similar to using grep or find in Unix.) But this is pretty ugly. I'd strongly recommend a redesign of some sort so you don't have to do this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic