This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading Files  RSS feed

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand there are limitations on accessing the native file system with MIDP, but will I have problems reading a local text file that I include with my JAR?
Thanks,
Drew
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's in the JAR, then it's also in the classpath.
you should be able to read the file as a resource (this should work regardless of whether it's in a JAR or not).
InputStream stream = getClass().getResoureAsStream("/yourfile.ext");
is one way to open an input stream on the resource.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!