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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:48:39+00:00 2026-06-13T11:48:39+00:00

I have a more complex program that involves using what’s written in a text

  • 0

I have a more complex program that involves using what’s written in a text file but it wasn’t working at all, nothing was being displayed and everything is dependent on the file. If i just make the string equal to something in my code and get rid of reading from the file then it works. I tried something as simple as displaying the line that is read but it doesn’t display anything when i run it.

Edit: It can’t find the path to the file… where is the default file usually in? The file is in the same directory as the program but it can’t find it, why?

public static void main(String[] args) {
    String s;
        try {
            FileReader fstream=new FileReader("input.txt");
            BufferedReader in=new BufferedReader(fstream);

        while((s=in.readLine())!=null){
        System.out.print(s);


        }}catch(IOException e){
            System.exit(0);
        }
    }
}
  • 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-13T11:48:40+00:00Added an answer on June 13, 2026 at 11:48 am

    Don’t ignore exceptions. If nothing is read, it’s probably that an exception is thrown. Instead of letting it bubble and telling you what’s wrong, you catch it and exit silently. That’s like buying a fire alarm and setting its sound volume to 0: you’ll never know there is a fire.

    Transform your program to

    public static void main(String[] args) throws IOException {
        String s;
        FileReader fstream=new FileReader("input.txt");
        BufferedReader in=new BufferedReader(fstream);
    
        while((s=in.readLine()) != null) {
            System.out.print(s);
        }
    }
    

    and see what happens.

    Also, I removed the call to readLine() inside the loop. The line has already been read at this point.

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

Sidebar

Related Questions

I have a simple recursive function RCompare() that calls a more complex function Compare()
I have been trying to create a program using perl www::Mechanize that will follow
I have a complex issue at hand. I have developed a program that takes
Summary: I have a struct that is read/written to file. This struct changes frequently,
I have to build a more complex custom view in Android. The final layout
I have more than one Event Listener that calls a specific function, and I
I have more or less been able to understand and implement all these concepts
i have more viewcontroller that start from rootviewcontroller. So for example i start with
I have more than 3000 members on a site built using wordpress. I am
So the current situation is I have a program that is completely utilizing MEF.

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.