文件流IO

1.文件可认为是相关记录或放在一起的数据的集合
2. File 类用于访问文件或目录的属性
File file = new File( String pathname );
3 .流是指一连串流动的字符,是以先进先出方式发
送信息的通道。
4. 文件的读写
(1)文本文件的读写
用FileInputStream和FileOutputStream读写文本文件
用BufferedReader和BufferedWriter读写文本文件
(2)二进制文件的读写
使用DataInputStream和DataOutputStream读写二进制文件
使用文件流的步骤:
5. InputStream类常用方法
int read( )
int read(byte[] b)
int read(byte[] b,int off,int len)
void close( )
int available()
6. 子类FileInputStream常用的构造方法
FileInputStream(File file)
FileInputStream(String name)
7.OutputStream类常用方法
void write(int c)
void write(byte[] buf)
void write(byte[] b,int off,int len)
void close( )
8.子类FileOutputStream常用的构造方法
FileOutputStream (File file)
FileOutputStream(String name)
FileOutputStream(String name,boolean append)
9.
(1)Reader类常用方法
int read( )
int read(byte[] c)
read(char[] c,int off,int len)
void close( )
(2)子类BufferedReader常用的构造方法
BufferedReader(Reader in)
(3)子类BufferedReader特有的方法
readLine()
10.
(1)Writer类常用方法
write(String str)
write(String str,int off,int len)
void close()
void flush()
(2)子类BufferedWriter常用的构造方法
BufferedReader(Writer out)
11. 引入相关的类
创建输入流/l输出流对象
读取/写入文本文件的数据
关闭相关的流对象

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值