package package3;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class OutputStreamWriterDemo {
public static void main(String[] args) throws IOException {
//OutputStreamWriter(OutputStream out) 创建一个使用默认字符编码的OutputStreamWriter
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("day04\\src\\osw.txt"));
//void write(int c)写一个字符
// osw.write(97);
// //void flush() 刷新流
// osw.flush();
//close(): 关闭流,释放资源,但是在关闭之前会先刷新流。一旦关闭,就不能再写数据
//osw.close();
//void write(char[] cbuf) 写入一个字符数组
char[] cha ={'a','b','t','i'};
// osw.write(cha);
//void write(char[] cbuf, int off, int len) 写入字符数组的一部分
// osw.write(cha,1,3);
//void write(String str) 写入一个字符串
osw.write("dwgui");
//void write(String str, int off, int len) 写一个字符串的一部分
osw.write("wedcx",1,3);
osw.close();
}
}
标签:字符,OutputStreamWriter,方式,int,void,osw,write,流写
From: https://www.cnblogs.com/knlf/p/16807866.html