Where to place a text file for use with a Java project in Eclipse

I placed a text file myapp.txt in the folder ~/workspace/PayrollApp/src/org/username/payrollapp. However, it was not opening in the Java program.

To make it work correctly, I had to do use the following path in the Java program when opening the file:

Code as follows:

   try {
      FileReader fr = new FileReader("src/org/username/payrollapp/pay.txt");
      BufferedReader br = new BufferedReader(fr);
      String line = null;
      while ((line = br.readLine()) != null) {
         String[] result = line.split(":");
         result[1] = result[1].replaceAll("~~", "nn");
         helpText.append(result[0] + ": " + result[1] + "n");
   } catch (IOException ex) {

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s