IO 流详细解答,博主亲自手敲代码,快速上手

Reader 和 Writer
Java 语言中最基本的两个字符输入输出类。
其他所有字符输入输出流类都继承自这两个基类。
这两个类都是抽象类,不能创建它们的实例,只能使用它们的子类


[](()File 类的使用
=======================================================================
File 类用来代表文件和文件夹。主要作用有两个:获取文件或者文件夹的属性; 实现对文件、文件夹的创建和删除。
[](()使用 File 获取文件或文件夹属性
===============================================================================


[](()使用 file 创建文件
=========================================================================

这样虽然可以达到基本效果,但是如果要添加文件在不存在得目录之下, 就需要先去创建目录

[](()字节流
==================================================================
[](()完成文件的复制
======================================================================
创建两个流对象,同时创建了两个输入输出流对象

读取字节对象

[](()关闭资源

[](()缺点

[](()使用数组复制文件
=======================================================================

当复制之后,因为数组的局限性,会多出很多空格
可以再遍历的时候进行设置

从 0 开始,一直写到 read 的个数,read 是字节的个数
如果我们重复刚刚的步骤,那么将会重新覆盖之前的内容,想要不覆盖,而是拼接的话,需要再写入流中设置为 true

[](()字符流
==================================================================
使用方法与上面描述的差不多
创建流对象


评论