UTF-8 on the command line

hi I want to run java code on the command line that reads utf-8

How can i do this

+6
java command-line
source share
2 answers

run java with

java -Dfile.encoding=UTF8 <Your class Name> 
+12
source share

There are methods in Java classes that accept encoding. See, for example, InputStreamReader (java.io.InputStream, java.nio.charset.Charset).

http://download.oracle.com/javase/6/docs/api/java/io/InputStreamReader.html

But first, make sure you read the Java Internationalization FAQ, so you'll understand how Java handles Unicode:

http://java.sun.com/javase/technologies/core/basic/intl/faq.jsp

+2
source share

All Articles