Writing UTF-8 Encoded Data : OutputStreamWriter « File Input Output « Java






Writing UTF-8 Encoded Data

 

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;

public class Main {
  public static void main(String[] argv) throws Exception {

    Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("outfilename"),
        "UTF8"));
    out.write("asdf");
    out.close();
  }
}

   
  








Related examples in the same category

1.new OutputStreamWriter(fos, "UTF8")new OutputStreamWriter(fos,
2.Writing ISO Latin-1 Encoded Data