package com.io;
import java.io.*;
public class TestOutputStream
{
public static void main(String[] args)
{
OutputStream os=null;
try
{
os=new FileOutputStream(new File("res/test.txt"));
//向文件中写入数据
String content="good morning";
byte[] data=content.getBytes();
os.write(data);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
os.close();//关闭输出流
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
原文:https://www.cnblogs.com/verejava/p/9227200.html