Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java command - argument question

 
hui man
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java classname [arg1] [arg2] ... where argX contains non-english characters

i am now trying to run java command with non-english characters as arguments. the args[] array i get from main() cannot show those characters (it just shows "???"). how can i change the charset of system.in to utf8 before the program gets into main() so that i can get those characters correctly? please give me some suggestions. thanks!
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to use
Locale class in java.util package
 
hui man
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please explain a bit more?
public static void main(String[] args) {
System.out.println(args[0]);
...
}
Now, if args[0] is in Chinese, how can I display it correctly using Locale class? Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic