导图社区 复习
这是一篇关于期末复习的思维导图,其内容主要分为两个部分讲述,一部分为文件/IO流,另一部分为集合内容
编辑于2022-06-17 17:25:07Java复习
文件/IO流
File文件
File(String)
isFile()判断是否为文件
exists()判断文件是否存在
isDirectory()判断是否为路径
mkdirs()创建多级目录
createNewFile()创建新文件
字节流
InputStream
常用方法
close()
read(byte[] b)
read(byte[] b,int off,int len)
字节内存流:ByteArrayInputSteam
FileOutputStream
OutPutStream
常用方法
close()
flush()
writer(byte[] b)
writer(byte[] b,int off,int len)
ByteArrayOutputStream
字节打印流:PrintStream
构造方法(OutPutStream out)
println()
FileOutputStream
FileOutputStream(File file)
FileOutputStream(File file, boolean append) true时追加新内容
字符流
数据将先经过缓冲区使用完后最好关闭或者刷新否则会影响输出结果
Reader
常用方法:
close()
int read()读取单个数据
int read(char[]buf)读取数据到数组,返回读取长度
子主题
转换流:InputStreamReader
字符内存流:CharArrayReader
字符缓冲流BufferedReader
构造:BufferedReader(Reader in)
readLine()
FileReader(File file)
Writer
常用方法
flush()
close()
writer(String data)
writer(byte[] cbuf)
append(CharSequence csq)
CharSequenece是一个字符串接口定义的字符串是可读可写的
OutputStreamWriter
CharArrayWriter
字符打印流:PrintWriter
集合
Collection接口
核心方法
boolean add(E e)添加元素
void clear()清空集合
boolean contains(Object o)判断元素是否存在
Object[] toArray()集合转化为数组
int size()取得元素个数
Iterator<E>iterator()实例化Iterator接口
List
扩展方法:
E get(int index)根据index取得元素
E set(int idex,E element)修改内容
ArrayList
LinkedList
Set
HashSet(无序)
ThreeSet(有序)
Map
常用方法
Set<Map.Entry<K,V>> entrySet()装换为Set集合
Set<K> keySet()取出所有的key
HashMap K,V可以为空
ThreeMap
Hashtable key或值都不能为空