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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:14:28+00:00 2026-06-13T05:14:28+00:00

This isn’t a repeat of a previous question, I have found out the issue

  • 0

This isn’t a repeat of a previous question, I have found out the issue is with the Process.

I have a problem with my program whereby special characters are seemingly lost in the InputStream of a Java Process.

The code I am using is as follows:

String command = "/usr/local/bin/getTitle <URL>";
Process shellCommand = Runtime.getRuntime().exec(command);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(shellCommand.getInputStream(), "UTF-8"));
String output = null;
while ((output = stdInput.readLine()) != null) {
    System.out.println(output);
}

If I run the ‘command’ from the command line, I get the following output:

PSY_-_GANGNAM_STYLE_(강남스타일)_M_V

However, the output of System.out.println(output); is as follows:

PSY_-_GANGNAM_STYLE_()_M_V

And this completely breaks my program.

I’m completely stumped, and I haven’t found anything even remotely related to this in my search. Any help greatly appreciated! Thanks in advance.

UPDATE:

If I change command as follows:

String command="echo 'PSY_-_GANGNAM_STYLE_(강남스 타일)_M_V'";

Then when printing the output the special characters are displayed correctly. Does this help in understanding where the problem lies?

  • 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-13T05:14:29+00:00Added an answer on June 13, 2026 at 5:14 am

    It seems pretty clear that this problem is caused by mismatching character encodings somewhere. The two places it could be are in the Reader stack that is reading from the external process, or the PrintStream stack for System.out. (The latter seems unlikely).

    Here’s what I’d do:

    • Run the locale command from the command line to see what character encoding is used by your command shell.

    • Check that the encoding is the same as the Java default character encoding

    • Check that they are both the same as the encoding you are using to read from the external process. (You have hard-wired that to “UTF-8” …)

    If that doesn’t reveal the source of the problem, try replacing the command string with "locale" to see what locale settings get propagated to the external process.

    And if that doesn’t work, try capturing the output from the external command as bytes, displaying them in hexadecimal, and trying to hand decode them as UTF-8 and as other possible character sets.

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

Sidebar

Related Questions

This isn't really a technical question, but I essentially have two sites, a mobile
This isn't about a specific problem I'm having, but I have to clear something
This isn't a huge problem, but ideally i'd like to sort it out if
This isn't solved, but I found out why: MySQL View containing UNION does not
This isn't a question of what stress testing tools are out there. I'm afraid
This isn't really a question on a problem; I've solved it my own (after
This isn't much of a problem, really, it's entirely out of curiosity. For a
This isn't the best question ever, but since search engines feel the need to
This isn't a question that I am expecting a specific answer to since it
This isn't strictly a programming question, but I'm asking it here because it's certainly

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.