[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(); } }