[Java 12 IO] 字符编码初步

字符编码初步
package com.qunar.basicJava.javase.io;

import java.io.*;

/**
 * Author: libin.chen@qunar.com  Date: 14-6-6 10:01
 */
public class Encoding {
    public static void main(String[] args) throws IOException {

        System.out.println(System.getProperty("file.encoding"));
        // 系统本地的编码是 UTF-8

        File file = new File("/home/hp/tmp/test.txt");
        OutputStream outputStream = new FileOutputStream(file);
        byte b[] = "中国,你好!".getBytes("UTF-8");
        outputStream.write(b);;
        outputStream.close();
    }
}

posted @ 2014-06-06 10:55  小尼人00  阅读(124)  评论(0编辑  收藏  举报