第10章 java的输入输出
流概念
Java用于输入输出流的类
数据池流的使用
处理流的使用
文件随机读取
1
流概念
Java使用流的机制实现输入输出。
流:是一个数据序列。有两种流:
1. 输入流
2. 输出流
第10章 java的输入输出
2
流概念
设备驱动程序
设备驱动程序
设备驱动程序
设备驱动程序
设备驱动程序
OS
独
立
于
设
备
的
I/O
层
提供
I/O层
(类层)
应用
程序
应用
程序
应用
程序
3
流概念
1. 输入流
通过打开一个连接到数据源(文件、内存或网络端口上的数据)的输入流,程序可以从数据源上顺序读取数据。
4
流概念
1. 输入流
读数据的逻辑为:
open a stream
while more information
read information
close the stream
第10章 java的输入输出
5
流概念
2. 输出流
通过打开一个连接到目标的输出流,程序可以向外部目标顺序写数据。
第10章 java的输入输出
6
流概念
2. 输出流
写数据的逻辑为:
open a stream
while more information
write information
close the stream
第10章 java的输入输出
7
Java用于输入输出流的类
按所读写的数据类型分两类:
字符流类(Character Streams) 字符流类用于向字符流读写16位二进制字符。
字节流类(Byte Streams) 字节流类用于向字节流读写8位二进制的字节。一般地,字节流类主要用于读写诸如图象或声音等的二进制数据。
第10章 java的输入输出
8
Java用于输入输出流的类
:
说明:它们是抽象类,不能直接创建对象。
第10章 java的输入输出
9
Java用于输入输出流的类
1. InputStream 方法
The three basic read methods:
int read()
int read( byte[] buffer)
int read( byte[] buffer, int offset, int length)
The other methods:
void close()
int available()
skip( long n)
第10章 java的输入输出
10
第10章 java的输入输出 来自淘豆网m.daumloan.com转载请标明出处.