Java: Which are the implicit encodings used for Sytem.out/in/err, files?
20:45 10 Nov 2020

First task: I want to read from System.in into a reader. It seems that this is done via

InputStreamReader cin = new InputStreamReader(System.in);

Well there are other constructors including an encoding. It is not clear what there the default encoding is. As I understand, System.in is just a stream of bytes. Whereas InputStreamReader reads chars. But where does constructor of InputStream know the charset? Do i have to apply a specific charset? if so which one or do i have to leave it away?

According question concerning System.out and System.err. Both seem to be print streams and in particular reading bytes.

OutputStreamWriter out  = new OutputStreamWriter(System.out);

ok choosing the right encoding or do i have to use a different constructor?

What about System.err?

Also what are the charsets????

Same question i have for PipedReader/Writer. At least they must coincide, right?

For StringWriter/Reader: same encoding as string, i.e. utf8, right?

Last question concerning files. FileReader/Writer are subclasses of InputStreamReader/Writer. This seems reasonable, since files are a sequence of bytes. But unlike constructor of InputStreamReader/Writer, which have constructors with charsets, FileReader/Writer do not. how can they know the encoding of the file???

Thanks for clarifying.

java encoding charset