I need to convert text file to the String, which, finally, I should put as an input parameter (type InputStream) to IFile.create (Eclipse). Looking for the example or how to
You need to specify the encoding of the InputStreamReader
using the Charset
parameter.
// ↓ whatever the input's encoding is
Charset inputCharset = Charset.forName("ISO-8859-1");
InputStreamReader isr = new InputStreamReader(fis, inputCharset));
This also works:
InputStreamReader isr = new InputStreamReader(fis, "ISO-8859-1"));
See also:
SO search where I found all these links: https://stackoverflow.com/search?q=java+detect+encoding
You can get the default charset - which is comes from the system the JVM is running on - at runtime via Charset.defaultCharset()
.