普通文件流和随机读写流区别
FileInputStream和FileOutputStream
FileReader和FileWriter
RandomAccessFile
二者区别:app
1.流向分类差异dom
普通文件流:分输入流和输出流
随机读写流:既是输入流也是输出流
2.基本方法区别svg
普通文件流:拥有全部共性方法,
好比read(),write(),close(),flush(),skip()等等方法
随机读写流:除了拥有这些共性方法,还有本身特有的方法,
好比readLine(),seek(),skipBytes()等等方法
特别注意:随机读写流没有flush()方法
3.构造方法区别.net
普通文件流:
1)输入流:参数都文件路径
FileInputStream(File file)
FileInputStream(String name)
2)输出流:参数1--都是文件路径;
FileOutputStream(File file)
FileOutputStream(String name)
参数2 append:
true时--写入时不覆盖原有内容,而是在文件内容后面接着写;
false--写入时会覆盖原有内容,没有第二个参数时默认是false
FileOutputStream(File file, boolean append)
FileOutputStream(String name, boolean append)
随机读写流:
参数1:都是文件路径;参数2:是读写模式,只有两个取值--r或rw
RandomAccessFile(File file, String mode)
RandomAccessFile(String name, String mode)
4.读写位置区别线程
普通文件流:只能在指定位置【读取】--skip()方法,不能指定位置写入
随机文件流:能够在指定位置进行【读写】,使用seek()方法
5.应用区别code
普通文件流:使用普通文件流不能进行多线程复制
随机读写流:能够进行多线程复制