• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get InputStream from a file with absolute path?

 
Jack Wanes
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys:

If I have file with a absolute path that may be inside/outside
my Eclipse plugin, I want to get an InputStream from it. It just keeps giving me null for "is":

String absFilePath = "/D:/my_dir/.../sample_file.txt";
InputStream is = getClass().getResourceAsStream(absFilePath);

regards,
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you should read the API Javadoc about getResourceAsStream(String name)

Now, while you do that, I believe that since you already have the full path to the file it is simpler to say:



Does this help?
 
Jack Wanes
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Edwin:

That solved the problem.


Originally posted by Edwin Dalorzo:
I believe you should read the API Javadoc about getResourceAsStream(String name)

Now, while you do that, I believe that since you already have the full path to the file it is simpler to say:



Does this help?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!