天天看点

输出流OutputStream

public class OutputStreamDemo {

	public static void main(String[] args) throws IOException {
		String str = "把现在写的内容复制到J:/Java安装包/20190401/OutputStreamDemo.txt里面";
		try {
			//创建一个输出流
			 OutputStream OPS= new FileOutputStream("J:/Java课程资料/20190401/OutputStreamDemo.txt");
			 //将str的byte数组数据写入到输出流
			 OPS.write(str.getBytes());
			 OPS.flush();
			 OPS.close();
			 
			
		} catch (FileNotFoundException e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
}
           

执行代码如下(这里没输出,实质上已经发生变化):

输出流OutputStream

没执行代码之前:

输出流OutputStream

执行代码之后:

输出流OutputStream
输出流OutputStream