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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:50:49+00:00 2026-05-28T07:50:49+00:00

BufferedReader buf2=new BufferedReader( new InputStreamReader(new FileInputStream(D:/info.txt))); Out of these two methods for reading the

  • 0
BufferedReader buf2=new BufferedReader(
    new InputStreamReader(new FileInputStream("D:/info.txt")));

Out of these two methods for reading the contents of a file which method is better and why?

BufferedReader buf=new BufferedReader(new FileReader("D:/info.txt"));
  • 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-05-28T07:50:50+00:00Added an answer on May 28, 2026 at 7:50 am

    Both lines are equivalent; in both cases you’ll get a BufferedReader which will allow you to read text from the file.

    A possible advantage of the first approach is that you can change it slightly to specify the character encoding that you want to use for reading the file, for example:

    BufferedReader buf2 = new BufferedReader(new InputStreamReader(
        new FileInputStream("D:/info.txt"), "UTF-8"));
    

    FileReader does not allow you to specify the character encoding and will always use the default character encoding of your platform, which is not always what you want.

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

Sidebar

Related Questions

Case 1: BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream(file) ) ); br.close();
I read a UTF-8 file by: br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), Charset.forName(UTF-8))); I
try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.println(Enter the continent;); String CN =
I'm reading an html file like this: try { BufferedReader bufferReader = new BufferedReader(new
package com.test.methods; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException;
System.out.print(>> ); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String input = br.readLine(); I would
I'm reading numbers from a txt file using BufferedReader for analysis. The way I'm
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println(Enter the String:); String str = br.readLine();//error: must
I'm reading a file using bufferedreader, so lets say i have line = br.readLine();
I'm reading a local file using a BufferedReader wrapped around a FileReader: BufferedReader reader

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.