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

  • Home
  • SEARCH
  • 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 7912283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:33:43+00:00 2026-06-03T13:33:43+00:00

I have the following code: BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); System.out.print(Enter: ); String

  • 0

I have the following code:

    BufferedReader inFromUser =
            new BufferedReader(new InputStreamReader(System.in));

    System.out.print("Enter: ");

    String m = inFromUser.readLine();

    BufferedReader br = new BufferedReader(new FileReader(m));

    String text;

    while((text = br.readLine()) != null){
        System.out.println(text);
    }

    br.close();

And when reading in the string from the user the file can never be found. I don’t know what is happening when the string is passed but it becomes unfindable. Although the file is very much there.

I have run tests and when I replace the newFileReader(m) with newFileReader(“Lab3/test”) the file is found, but when I enter the “Lab3/test” into the system(Via the String m = inFromUser.readLine();) to read it, it’s read in and printed as “Lab3/test” but the file reader never finds the file when the string is passed into the file reader(Via m), when the string is the exact same.

I’ve googled a bit but trying to explain that is a pain.

A thank you in advance, Sam

  • 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-03T13:33:48+00:00Added an answer on June 3, 2026 at 1:33 pm

    You need to enter the file name without quotes. If you enter it with quotes, then the file name must contain the quotes as well.

    If you use file name such as Lab3/test, then Java will search for the file in the current working directory. The current working directory is normally where the application was started. I might be easier if you enter the complete, absolute file name, such as C:\Users\Smithers\Dropbox\Software Engineering Code\Eclipse\Networking\Lab3\test.

    It doesn’t matter if you use backslashes or forward slashes.

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

Sidebar

Related Questions

I have the following code: try { reader = new BufferedReader(new FileReader(file)); String records
I have following code class User attr_accessor :name end u = User.new u.name =
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int
I have the following code which searches a text file on my phone's sd
So I have the following code where I should read a Text File (This
I have the following code and I can't figure out why it won't work:
I have the following code in a java Web Service: public boolean makeFile(String fileName,
I have the following host package clserver; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import
I have the following code snippet to read the full contents of a text
I have the following code example below. Whereby you can enter a command to

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.