IO操作基本步骤

package com.study02;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class IOtest03 {
public static void main(String[] args) {
File src = new File("abc.txt");
FileInputStream is = null;
try {
is = new FileInputStream(src);

for (int i = is.read(); i != -1; i=is.read()) {
System.out.print((char)i);
}

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
if (is!=null) {
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

}
}

posted @ 2019-10-27 15:10  Princess1  阅读(534)  评论(0编辑  收藏  举报