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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:15:40+00:00 2026-06-03T00:15:40+00:00

first time post here. I am in the process of writing a Java program

  • 0

first time post here.

I am in the process of writing a Java program that takes an input text file, reads the contents, and then prints them to the screen and also creates an output file with the contents. I have set up the necessary writers, but when I try to use BufferedReader readername = new BufferedReader(new FileReader(inFile)); it gives me the error in the title.

Any ideas what’s causing it?

Here’s the code.

public class FileReader 
{
    public static void main(String[] args) throws IOException
    {
        try
        {
        File inFile = new File("inputText.txt");
        BufferedReader reader = new BufferedReader(new FileReader(inFile));
        String line = null;
        BufferedWriter writer = new BufferedWriter(new FileWriter("Contents.txt"));

        while ((line=reader.readLine()) != null)
                    {
                        writer.write(line);
                        System.out.println("File 'Contents.txt' successfully written");
                        System.out.println(line);
                    }
        }
        catch (IOException e)
        {
            System.out.println(e);
        }
    }
}
  • 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-03T00:15:43+00:00Added an answer on June 3, 2026 at 12:15 am

    Use the fully qualified class name java.io.FileReader since you have a class already called FileReader when calling a BufferedReader, like so:

    BufferedReader reader = new BufferedReader(new java.io.FileReader(inFile));
    

    Without fully qualifying your FileReader (or specifying imports), the compiler will use your declared FileReader.

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

Sidebar

Related Questions

This is my first time here so I hope I post this question at
this is my first time to post a question here, I will try to
Hello and thank you for your time :) My first post here, but I
this is my first time to post here. I have a problem on my
This is the first time for me to post here, so sorry if I
My first post here, please be gentle. =) I work for a company that
Every time I try to post to twitter in my rails app, the first
this is my first post on this website, but I'm all the time getting
first time SO user :) I know that I can format a number like
first time posting here. I'm using a loop to create 3 buttons, but 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.