Writer: write(char[] cbuf) : PrintWriter « java.io « Java by API





Writer: write(char[] cbuf)

   
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class Main {
  public static void main(String[] args) {
    try {
      char[] chars = new char[2];
      chars[0] = '\u4F60';
      chars[1] = '\u597D';
      String encoding = "GB18030";
      File textFile = new File("C:\\temp\\myFile.txt");
      OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(textFile), encoding);
      writer.write(chars);
      writer.close();
    } catch (IOException e) {
      System.out.println(e.toString());
    }
  }
}

   
    
    
  










Related examples in the same category

1.new PipedWriter()
2.new PrintWriter(BufferedWriter, boolean autoFlush)
3.new PrintWriter(Writer out)
4.PrintWriter: close()
5.PrintWriter: print(char c)
6.PrintWriter: print(int i)
7.PrintWriter: println(Object x)
8.PrintWriter: println(String x)
9.PrintWriter: println(char x)
10.PrintWriter: println(double x)
11.PrintWriter: println(float x)
12.PrintWriter: println(int x)
13.PrintWriter: println(long x)
14.PrintWriter: println()