FileReader
is an InputStreamReader
which uses FileInputStream
as input, and an InputStreamReader
uses the default charset when constructed without specified charset.
In the source code jdk10, it use Charset.defaultCharset()
:
public static StreamDecoder forInputStreamReader(InputStream in,
Object lock,
String charsetName)
throws UnsupportedEncodingException
{
String csn = charsetName;
if (csn == null)
csn = Charset.defaultCharset().name(); // get default charset
try {
if (Charset.isSupported(csn))
return new StreamDecoder(in, lock, Charset.forName(csn));
} catch (IllegalCharsetNameException x) { }
throw new UnsupportedEncodingException (csn);
}
which
Returns the default charset of this Java virtual machine.
The default charset is determined during virtual-machine startup and
typically depends upon the locale and charset of the underlying
operating system.
You can print it:
public static void main(String[] args) {
System.out.println(Charset.defaultCharset());
}