Hello,
Im writing a swing application (not an online one) and I'm trying to access text files from a jar file
that's not apart of the jar.
But Im having trouble accessing them.
heres apart of my code:
public static void main(String args[]) {
final SeqGUI Sequence1 = new SeqGUI();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
Sequence1.setVisible(true);
...
String URL3 = "textdocs/contig2.txt";
try {
int one = 1;
seq_gene = Sequence1.fileOpener(URL0, one);
}
...
}
public ArrayList fileOpener(String inputmain, int firstline) throws FileNotFoundException {
try {
if (firstline == 1) {
String input = new java.io.File("").getAbsolutePath();
Textbox.append(input+"\n");
input = new java.io.File("").getCanonicalPath();
Textbox.append(input+"\n");
input = System.getProperty("user.dir");
Textbox.append(input+"\n");
URL url = this.getClass().getResource("/"+inputmain);
if (url == null) {
Textbox.append(" File was not found in the class path. ");
}
else {
File fileh = new File(url.getFile());
System.out.println("I exists, somehow...");.
}
InputStream is = new FileInputStream(fileh);
.....
}
}
This returns:
/home/sean
/home/sean
/home/sean
File was not found in the class path. textdocs/contig2.txt