Sunday, May 22, 2011

How to identify File encoding in Java?



I have this error "cannot read the file xxxx.jsp" when i am accessing some jsp screen..

I am ran into this issue when try to access some jsp page in my project. I found that Input data was not encoded in UTF-8 but our default encoding on Windows was set to UTF-8.

I fixed the input data to be UTF-8 encoded. It works well.

You can either fix the input or change the default encoding to something else.

This is the useful info is

http://www-128.ibm.com/developerworks/java/jdk/linux/142/runtimeguide.lnx.en.html

If your system locale is using a UTF-8 encoding, some SDK tools might throw a sun.io.MalformedInputException. To find out whether your system is using a UTF-8 encoding, examine the locale-specific environment variables such as LANG or LC_ALL to see if they end with the suffix ".UTF-8". If you get this sun.io.MalformedInputException, change characters that are not within the 7-bit ASCII range (0x00 - 0x7f) and are not represented as Java Unicode character literals to Java Unicode character literals (for example: '\u0080'). You can also work around this problem by removing the ".UTF-8" suffix from the locale-specific environment variables; for example, if your machine has default locale of "en_US.UTF-8", set LANG to "en_US".

No comments:

Man Utd's next generation of wonderkids

Manchester United have set off on their pre-season United States tour with a number of young stars involved, but some other talents have lef...