Originally Posted by khyana
Firstly, when there is an encoding/decoding of a String into/from bytes, the charset is always an important matter. It can be implicit (the default charset of the platform) or explicit, but you always need to care about this.
Secondly, if you are using a (File)OutputStream because you are writing binary/mixed datas, it's ok to write a String as a sequence of bytes (depending on the format of the file you are writing, this is up to you to know if it has sense). In this case, use the other getBytes(String charsetName)
If you are writing a text-only stream, please wrap the (File)OutputStream in a OutputStreamWriter, so you can write at least "characters" and not simple bytes. And eventually use also another wrapper e.g. BufferedWriter. And please see the constructors of OutputStreamWriter to decide if you want to use a default charset or an explicit charset.
If you have doubts, explain what type of file you are writing.