字节输出流写入数据到文件:
字节输出流的使用步骤(重点)∶
1.创建一个FiLeoutputstream对象,构造方法中传递写入数据的目的地
2.调用Fileoutputstream对象中的方法write,把数据写入到文件中
3.释放资源(流使用会占用一定的内存,使用完毕要把内存清空,提供程序的效率)
public class File {
public static void main(String[] args) throws IOException {
//创建一个FileOutputStream对象,构造方法中传递写入数据的目的地
FileOutputStream stream = new FileOutputStream("D://ai.txt");
//调用FileOutputStream对象中的方法write把数据写入到文件中
stream.write("dwaf".getBytes());
//关闭流资源
stream.close();
}
}
文件存储的原理和记事本打开文:

搜索
复制
原创文章,作者:wure,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/272715.html