I have a very specific Java problem that is driving me nuts. Anyway, this is inside of an application I'm developing using the J2SE 5.0 JDK on a WinXP SP2 system.
The issue is that I have a single Jar file that I'm both reading configuration information from and writing information to. Now, one of the files I'm writing to this Jar I want to put inside a subdirectory, and I need to create this directory if it doesn't exist (which it won't the first time the application runs.) The process I am using is to create a File object and use the mkdir( ) function to create the folder. Then when I create the file object I use this directory handle in the constructor to create the file in that directory. And I add it to the Jar file and everything seems to work. But, when I call the entries( ) function on the Jar file and look at the Enumeration that is returned (and use the getName( ) on each entry), the one in the subfolder is listed as:
subfolder\file.cfg
and it has a backslash used as the directory deliminator. The parser I am using (and I must use this parser) requires a '/' as the directory deliminator. This has always worked up until now, because if from the operating system (outside of the program) if I use WinZip to add a subdirectory and file to the Jar file, then the Enumeration I get for that from the program is:
subfolder/file.cfg
If I view the contents of the Jar file in WinZip with files added both from within the program and externally, WinZip shows them the same way (the path field reads: subdirectory\ ), but the Java program interprets them differently. I am searching for a way to have the file I add inside the program to also be read as:
subfolder/file.cfg
I've tried a few different ideas (various constructors for the File object), obviously nothing has panned out yet. If anyone can offer any insight I would appreciate it greatly.
The issue is that I have a single Jar file that I'm both reading configuration information from and writing information to. Now, one of the files I'm writing to this Jar I want to put inside a subdirectory, and I need to create this directory if it doesn't exist (which it won't the first time the application runs.) The process I am using is to create a File object and use the mkdir( ) function to create the folder. Then when I create the file object I use this directory handle in the constructor to create the file in that directory. And I add it to the Jar file and everything seems to work. But, when I call the entries( ) function on the Jar file and look at the Enumeration that is returned (and use the getName( ) on each entry), the one in the subfolder is listed as:
subfolder\file.cfg
and it has a backslash used as the directory deliminator. The parser I am using (and I must use this parser) requires a '/' as the directory deliminator. This has always worked up until now, because if from the operating system (outside of the program) if I use WinZip to add a subdirectory and file to the Jar file, then the Enumeration I get for that from the program is:
subfolder/file.cfg
If I view the contents of the Jar file in WinZip with files added both from within the program and externally, WinZip shows them the same way (the path field reads: subdirectory\ ), but the Java program interprets them differently. I am searching for a way to have the file I add inside the program to also be read as:
subfolder/file.cfg
I've tried a few different ideas (various constructors for the File object), obviously nothing has panned out yet. If anyone can offer any insight I would appreciate it greatly.