/**
* 逐个读取文件内容
*
* IO流步骤
*
* 1.创建源
* 2.选择流
* 3.选择操作
* 4.关闭流
*
* @author breeziness
*
*/
public class IODemo01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
readTotxt();
}
public static void readTotxt() {
File file = new File("C:/Users/breeziness/Desktop/abc.txt");
InputStream is = null;
int temp = 0;
try {
is = new FileInputStream(file);
while ((temp = is.read()) != -1) {
System.out.print((char)temp);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}