一、定义:
输入输出技术用于处理设备之间的数据传输,指程序与外部设备或其他计算机进行数据交换的过程,比如读写文件。网络通信等针对程序而言,将外部数据读取到程序中称为输入,将程序数据输出到硬盘称为输出。
二、分类:
1、InputStream类——int read(),int read(byte[ ] b),publicvoidclose() throws IOException
2、OutputStream类
3、Reader类
4、Writer类
三、示例:
public class IODemo {
public static void main(String [] args){
String pathname = "D:\\Program Files (x86)\\java-code\\class\\tj\\rj\\box\\src\\IO\\1.txt";//确定源
FileInputStream fis = null;
try{
fis = new FileInputStream(pathname); // 打开流
//操作流
while(fis.read() != -1){
}
} catch(IOException e){
e.printStackTrace();
} finally {
try{
fis.close(); // 关闭流
} catch(IOException e){
e.printStackTrace();
}
}
}
}