输入输出流,用于处理设备间的数据传输,将外部数据读取到程序中称为输入,反之称为输出。而对其进行的输入输出操作以流的方式进行。
在java.io包中提供了各种流的类与接口,用于获取各种数据及使用方法输入输出数据
比如我们现在在d盘创建了一个HelloWorld的文件,通过以下方式就可以把它打印输出
package File;
public class FileInputStream {
public static void main(String[] args){
String Hello = "d:\\HelloWorld.txt";
int Read = 0;
FileInputStream fileInputStream = null;
try {
FileInputStream fileInputStream = new FileInputStream(Hello);\
while (Read = fileInputStream.read() != -1 ){
System.out.println((char)Read);
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
try {
fileInputStream.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}