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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:41:38+00:00 2026-05-24T10:41:38+00:00

I read a UTF-8 file by: br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), Charset.forName(UTF-8))); I

  • 0

I read a UTF-8 file by:

br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), Charset.forName("UTF-8")));

I would like to know what’s the charset of returned String after I invoke br.readLine()?

Eclipse on my Computer uses “GBK” as default charset.

  • 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-24T10:41:39+00:00Added an answer on May 24, 2026 at 10:41 am

    Technically, the file is been read using a charset of UTF-8 as you told the InputStreamReader to do so. The underlying bytes of the file content are been interpreted using UTF-8. The readLine() method returns a String which stores the characters internally in Java’s own UTF-16 charset.

    What happens thereafter is fully dependent on what you’re doing with this String. If you’re writing it back to a file using a Writer without specifying the charset, then the platform’s default will be used. If you’re displaying it to the stdout, then the stdout’s default charset will be used which is dependent on the runtime environment (command console? IDE? etc). If you’re saving it in a database, then it’s dependent on the JDBC driver configuration and/or the DB table encoding. Etcetera.

    Apparently you’re printing it to stdout in Eclipse’s console by System.out.println(). In that case, the GBK charset will be used to display the characters. That would malform any originally read UTF-8 characters which are not covered by GBK. You’d need to configure Eclipse to use UTF-8 as text file encoding. That can be done by Window > Preferences > General > Workspace > Text file encoding.

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

Sidebar

Related Questions

Trying to read an utf-8 encoded file in android... InputStreamReader reader = new InputStreamReader(assets.open(data.txt),
I want to know how to receive the string from a file in Java
I'm trying to read UTF-8 from a text file and do some tokenization, but
can anyone help? I have small procedure to read in an UTF-8 file with
I have a htm file can i read it as UTF-8 formatted file without
I'm having troubles with reading a UTF-8 encoded text file in Hebrew. I read
I have utf-8 file which I want to read and display in my java
I am trying to read a UTF-8 text file in Visual C++ 2010 using
I want to read UTF-8 input in Perl, no matter if it comes from
I want to read UTF-8 strings from a server that I have control of,

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.