Mark13426
Mark13426

Reputation: 2639

How to access a resource in Eclipse using a Java API

I imported a resource (resource being a GZIP file) into my Java project, but I'm not sure how I could access it from within the same project.

Java Resources -> srctest -> somepackagename -> MyClass.java (This is the class that wants to access the GZIP file)

Java Resources -> testdata -> someFile.gz

Upvotes: 0

Views: 1712

Answers (1)

Bhaskar
Bhaskar

Reputation: 7523

Have you tried this -

InputSteam is =  this.getClass().getClassLoader().getResourceAsStream("resources/someFile.gz") 

I am assuming the gzip file is on the same classpath as the current class.

Upvotes: 1

Related Questions