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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:07:15+00:00 2026-06-05T11:07:15+00:00

StringBuffer contents=new StringBuffer(); BufferedReader input = new BufferedReader(new FileReader(/home/xyz/abc.txt)); String line = null; //not

  • 0
StringBuffer contents=new StringBuffer();
BufferedReader input =  new BufferedReader(new FileReader("/home/xyz/abc.txt"));
String line = null; //not declared within while loop
while (( line = input.readLine()) != null){
    contents.append(line);
}
System.out.println(contents.toString());

File abc.txt contains

\u0905\u092d\u0940 \u0938\u092e\u092f \u0939\u0948 \u091c\u0928\u0924\u093e \u091c\u094b \u091a\u093e\u0939\u0924\u0940 \u0939\u0948 \u092

I want to dispaly in Hindi language in console using Java.

if i simply print like this
String str=”\u0905\u092d\u0940 \u0938\u092e\u092f \u0939\u0948 \u091c\u0928\u0924\u093e \u091c\u094b \u091a\u093e\u0939\u0924\u0940 \u0939\u0948 \u092″;

System.out.println(str);

then it works fine but when i try to read from a file it doesn’t work.

help me out.

  • 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-05T11:07:17+00:00Added an answer on June 5, 2026 at 11:07 am

    Use Apache Commons Lang.

    import org.apache.commons.lang3.StringEscapeUtils;
    
    // open the file as ASCII, read it into a string, then
    String escapedStr; // = "\u0905\u092d\u0940 \u0938\u092e\u092f \u0939\u0948 ..."
    // (to include such a string in a Java program you would have to double each \)
    
    String hindiStr = StringEscapeUtils.unescapeJava( escapedStr );
    
    System.out.println(hindiStr);
    

    (Make sure your console is set up to display Hindi (correct fonts, etc) and the console’s encoding matches your Java encoding. The Java code above is just the bare bones.)

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

Sidebar

Related Questions

This is my code: public static String sendPostRequest(String url) { StringBuffer sb = null;
I have this code: public void readTroops() { File file = new File(resources/objects/troops.txt); StringBuffer
What is the difference between String and StringBuffer in Java? Is there a maximum
I have a small java program that searches the contents of all *.txt files
I have a function designed to get a file's contents: bool getFileContents(std::string loc, std::string
Virtually every code example out there reads a TXT file line-by-line and stores it
All, I was wondering if clearing a StringBuffer contents using the setLength(0) would make
I have created two StringBuffer as follows StringBuffer buffer1 = new StringBuffer(Text); StringBuffer buffer2
The differences between StringBuilder and StringBuffer in Java are well documented and have been
How can we re assign the value of a StringBuffer or StringBuilder Variable? StringBuffer

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.