Is UTF-8 the default encoding in Java?
If not, how can I know which encoding is used by default?
Java – the default encoding of the JVM
character-encodingencodingjavajvm
Related Question
- Java – How to generate random integers within a specific range in Java
- C# – How to get a consistent byte representation of strings in C# without manually specifying an encoding
- Java – Does Java support default parameter values
- Java – Comparing Java enum members: == or equals()
- Java – How to convert a String to an int in Java
- Java – Why is subtracting these two times (in 1927) giving a strange result
- Java – Why is processing a sorted array faster than processing an unsorted array
- Java – Proper use cases for Android UserManager.isUserAGoat()
Best Solution
The default character set of the JVM is that of the system it's running on. There's no specific value for this and you shouldn't generally depend on the default encoding being any particular value.
It can be accessed at runtime via
Charset.defaultCharset()
, if that's any use to you, though really you should make a point of always specifying encoding explicitly when you can do so.