导图社区 java学习
关于java学习的思维导图,包含对文件进行操作;主要函数;构造器;字节流(节点流);字符转换流;数据流;缓存流;字符流;面向对象的三大特性等。
编辑于2021-12-02 16:59:10java
io
File类
对文件进行操作
主要函数
createNewFile();
mkdir()/mkdirs()
delete();
deleteOnExit();
在程序退出时删除
getPath();
返回路径
getName();
返回文件名
getParent();
返回所在目录
getAbsolutePath();
返回绝对路径
getCanonicalPath();
返回修正后的绝对路径,去除(.和..)
exists();
文件是否存在
isFile();
是否为文件
isDirectory();
是否为目录
listFiles();
返回文件数组
构造器
new File("path");
new File(String parent,String child);
new File(File parent,String child);
字节流(节点流)
InputStream抽象类
FileInputStream
int read();
Int四字节最后一个
int read(byte[] bt);
放入byte[]数组中
int read(byte[] bt,off,leng);
while((int ch = fis.read(bt)) != -1)
循环读取
返回-1代表文件结束
OutputStream抽象类
FileOutputStream
write(int ch);
write(byte[] bt);
write(byte[],off,len);
write(str.getBytes());
测试输出
没有直接写入String的方法
构造器
FileOutputStream(File,boolean append);
FileOutputStream(stringpath,boolean append);
FileOutputStream(File file);
FileOutputStream(String path);
会创建覆盖文件,加true会追加内容
字符转换流
InputStreamReader
OutputStreamWriter
构造器参数为字节流
数据流
DataInputStream
DataOutputStream
Int/double等八种基本
对象流
ObjectInputStream
ObjectOutStream
序列化对象进行
实现 Serializable接口
关键字 transient
不参与序列化属性
transient private String car;
缓存流
BufferedInputStream
BufferedOutputStream
字符流
直接读取字符
可以直接从文件中读取字符
FileReader
FileWriter
集合
Collection类
结构
Set接口
HashSet
SortedSet
EnumSet
List接口
ArrayList
Vector
Stack
LinkedList
Queue接口
PriorityQueue
Deque
ArrayDeque
LinkedList
Map
HashMap
Hashtable
Properties
SortedMap接口
TreeMap
WeakHashMap
IdentityHashMap
EnumMap
https://www.cnblogs.com/LittleHann/p/3690187.html
面向对象的三大特性