How to encode to windows 1252 in Java while writing to the file?
file, java
Solution
You can use an `OutputStreamWriter`.
Writer out = new OutputStreamWriter(new FileOutputStream(yourFile), "windows-1252");
Use the typical `Writer` methods to write output to your File (or wrap it, or declare it as `OutputStreamWriter`).
The constructor also accepts a `Charset` instead of the `String` charset name. You can get it like so
Charset windows1252 = Charset.forName("windows-1252");
Problem
If I were to encode the data in windows-1252 format and write it to the file, how to set the content type in java?