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 8187001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:24:58+00:00 2026-06-07T02:24:58+00:00

In the following the code I keep getting the error (No such file or

  • 0

In the following the code I keep getting the error “(No such file or directory)”

public void readFile() throws IOException {
        reader = new BufferedReader(new FileReader("map1.txt"));

    while(true) {
        String line = reader.readLine();
        System.out.println(line);
        if(line == null) {
            reader.close();
            break;
        }
    }
}

I get this same error when I try to read images / anything really. But in the examples I’ve seen of how to use file readers they all just put in the name of the files and nothing else. In this case the map is in a separate folder in the src file called Maps. I’ve tried various specifications of “/Maps/map1.txt” but nothing seems to work. How do I get this file to read?

(I’m on a mac as well. I don’t know if that changes things.)

Update

Seems like it is netBeans’ fault. It only looks the project folder. I think I’ll start another topic asking how to remedy this later. Thank you for all the help everyone.

  • 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-07T02:24:59+00:00Added an answer on June 7, 2026 at 2:24 am

    In this case the map is in a separate folder in the src file called Maps.

    I assume you have a folder named src which has your java files; in this same folder there is a folder named Maps which has map1.txt.

    Now,

    reader = new BufferedReader(new FileReader(“map1.txt”));

    Is going to to try to open the file map1.txt in the current directory. Which directory this is depends on the IDE you use; but you should be able to change it.

    If you change it to the folder which has the file it should work.

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

Sidebar

Related Questions

Getting error with the following code: import java.util.Scanner; public class FahrenheitToCelsius{ public static void
With the following code, I keep getting error C2535 when I compile. It's complaining
I keep getting an error with the following bit of code. It is probably
I'm trying to get http://www.gelens.org/code/gevent-websocket/ running and keep getting the following error. socket_id=1 already
I keep getting an error, missing { after property for the following code. <script
I keep getting an error in the following code when I close the print
When I run the following code, I keep getting a glibc detected error when
I have the following code and keep getting the error: AttributeError: 'NoneType' object has
I'm running some code through JSHint and I keep getting the following error: Don't
When I run the following code, I keep getting this error: Traceback (most recent

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.