Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7735871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:36:30+00:00 2026-06-01T07:36:30+00:00

I have this error when I am trying to read the file: Exception in

  • 0

I have this error when I am trying to read the file:

Exception in thread "main" java.io.FileNotFoundException: \src\product.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at dao.Inventory.readFile(Inventory.java:30)
at view.InventoryView.init(InventoryView.java:33)
at view.InventoryView.<init>(InventoryView.java:21)
at view.InventoryView.main(InventoryView.java:211)

But the thing is, I have the product.txt in my src folder.

My code is the following:

  public void readFile() throws IOException {
            // input file must be supplied in the first argument
            InputStream istream;
                    File inputFile = new File("\\src\\product.txt");
                    istream = new FileInputStream(inputFile);

                    BufferedReader lineReader;
                lineReader = new BufferedReader(new InputStreamReader(istream));
                    String line;

                        while ((line = lineReader.readLine()) != null) {

                StringTokenizer tokens = new StringTokenizer(line, "\t");

                // String tmp = tokens.nextToken();
                // System.out.println("token " + tmp);
                ActionProduct p = new ActionProduct();
                prodlist.add(p);
                String category = p.getCategory();
                category = tokens.nextToken();
                System.out.println("got category " +category);

                int item = p.getItem();
                item = Integer.parseInt(tokens.nextToken());

                String name = p.getName();
                System.out.println("got name " +name);

                double price = p.getPrice();
                price = Double.parseDouble(tokens.nextToken());

                int units = p.getUnits();
                units = Integer.parseInt(tokens.nextToken());
            }
        }

I don’t think anything is wrong with my code. Also, I saw a similar post about a hidden extension like FILE.TXT.TXT, how would you show a hidden extension in MacOSX?? Any suggestions? (Would there be any other problem besides the hidden extension issue?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:36:32+00:00Added an answer on June 1, 2026 at 7:36 am

    /src/product.txt is an absolute path, so the program will try to find the file in the src folder of your root path (/). Use src/product.txt so the program will use this as a relative path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have encountered this error when trying to delete a cell, using a custom
I get this error when trying to link a win32 exe project. I have
I have a suspicion why this error happens when I am trying to push
So I'm trying to update my GridView, and I get this error: You have
This time I have an error which I have been trying again to figure
I have this error while trying to run my program. I am still wondering
I am currently trying to read an ofx file with java. But I get
I am trying to read a file located at C:\Users\Siddharth\Documents\aarti\yeh_vidhi_mangal.txt. Following code indicates that
I am trying to read data from an MS Project XML file. I have
i'm trying to read text from a text file that I have in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.