I'm just getting into using "Java Resource Files" and i have a few questions...
- I am hoping to distribute my program to others and I'm assuming JAR file isn't the best way. I'd probably go about it by "converting to exe" is this good practice? what are the limitations?
- If I convert to an exe does it keep the resource files?
- I'm actually just trying to use a resource file. This file is a text file and will just save the users directories for certain files so they don't need set them up every time they open the program. is this even the best way to go about it?
- how do you reference the resource file in the code itself?
Here is what I've done. created a new resource file and since I'm using Netbeans I can see its location under the files tab in the navigator it looks like this:
- Mainproject
- build
- classes
- myclass
- resources
- directories.txt
here is how i'm trying to access it but when i debug it is coming back null.
private void getPaths()//todo
{
try
{
InputStream is = getClass().getResourceAsStream("/resources/directories.txt");
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null)
{
System.out.println(line);
}
br.close();
isr.close();
is.close();
}
catch(Exception e)
{
}
}