Hey guys one of the aspects of a program of mine opens .txt files via the OpenDialog javax command. My bufferedreader works fine in my developing environment but when I try to export the project to a .jar my program doesn't seem to load in the data. I can still access the openDialog subview, pick the file, etc. but the file won't load and I'm not sure how to debug a jar so I'm unsure on whether the error is a bufferedreader or from the dialog itself. Like I said the program works fine when I compile and run BLueJ but for some reason when I create the .jar it stops after opendialog. Anyone familiar with this type of error?
For explanation, the method adds a deck of cards from a text file already shuffled. Card is declared as an ArrayList
card.clear();
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
String filename = chooser.getSelectedFile().getName();
try
{
FileReader reader = new FileReader(filename);
BufferedReader breader = new BufferedReader(reader);
String line;
while ((line = breader.readLine()) != null)
{
card.add(line);
displayField.append("\nAdded a " + line);
}
displayField.append("\nDeck Size: " + card.size());
breader.close();
} catch (FileNotFoundException e)
{
System.err.println("FileNotFoundException: " + e.getMessage());
} catch(IOException ex)
{
System.out.println(
"Error reading file '"
+ filename + "'");
}