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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:19:38+00:00 2026-06-07T13:19:38+00:00

I posted a similar question here: Read from a file containing integers – java

  • 0

I posted a similar question here: Read from a file containing integers – java but couldn’t get a decent reply.

Now I have written this new code which only reads a file and outputs the result.

I get a FileNotFoundException whenever I try to read from a file. The code is below:

import java.io.*;

public class second {

/**
 * @param args
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {

    File f = new File("C:\\Users\\Haroon\\workspace\\ppp\\temperature.txt");
    FileReader file = new FileReader(f);
    BufferedReader buf = new BufferedReader(file);

    String s = null;
    while((s = buf.readLine()) != null){
        System.out.println(s);
    }
}

}

This is strange because the file is in the project’s folder.
Any help would be appreciated.

  • 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-07T13:19:40+00:00Added an answer on June 7, 2026 at 1:19 pm

    That should work. Go to the location of the file, copy the path, paste it in your code, and escape the slashes. You are missing something.

    Also check that the name/extension of the file is correct, you could have something like “temperature.txt.txt”.

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

Sidebar

Related Questions

I've posted similar question here , but it was closed because I didn't explained
My question is very similar to the question posted here on stackoverflow but the
I have posted a question on here previously asking similar advise, but this project
My question is similar to a question previously posted but never really answered here:
Before I post this question, I found somehow similar question posted here . But
I'm trying to solve interviewstreet's median challenge. I saw a similar question posted here:
I saw a similar question being posted here, yet it did not help me
I know that this question is very similar to the question posted here .
I've seen a very similar question was posted but his solution didn't help. I'm
I posted a related question to no response but here I'll be less narrow.

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.