1.用getBytes()方法;
2.创建对象 String(arr,0,len);
package com.fenqing.Stream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class demo7_chinese {
public static void main(String[] args) throws IOException {
// test();
FileOutputStream fos=new FileOutputStream("zzz.txt");
fos.write("你好".getBytes());
fos.write("\r\n".getBytes()); //添加回车转到下一行\r\n
fos.close();
}
public static void test() throws FileNotFoundException, IOException {
FileInputStream fis =new FileInputStream("yyy.txt");
byte[] arr=new byte[3];
int len;
while((len=fis.read(arr))!=-1){
System.out.println(new String(arr,0,len));
}
}
}