java字节流到字符流的转换的一个demo

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_20172379/article/details/87917434

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

public class testtranform {
public static void main(String[] args) throws Exception {
File file = new File(“c:”+File.separator+“kwg4”+File.separator+“kwg4.txt”);
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
OutputStream os = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(os);
osw.write(“你是猪吗?嘿嘿”);
osw.flush();
osw.close();
}
}

猜你喜欢

转载自blog.csdn.net/qq_20172379/article/details/87917434