• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to convert an InputStream to an OutputStream?  RSS feed

 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get an InputStream using
InputStream is = this.getClass().getResourceAsStream( "myfile.txt" );
After processing it I want to write to the same file “myfile.txt”. How to do this? I only know this file is in the class file folder and I don’t know its absolute path.
Thanks.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd try something like this:
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jim!
It works.
URL url = this.getClass().getResource("test.xml");
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Drat. Obviously I meant getResource() rather than getResourceAsStream(). Anyway you seem to have worked that part out for yourself.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!