Paste_Image.png
import java.io.*;
public class MyReadFile {
public static void main(String[] args){
try {
File f = new File("D:/test2.txt");
FileInputStream fis = new FileInputStream(f);
System.out.println(fis.read());
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
}
java.io.FileNotFoundException: D:\test2.txt (系统找不到指定的文件。)
java.io.FileNotFoundException: D:\test2.txt (系统找不到指定的文件。)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at MyReadFile.main(MyReadFile.java:8)
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
import java.io.*;
public class MyReadFile {
public static void main(String[] args){
try {
File f = new File("D:/test2.txt");
FileInputStream fis = new FileInputStream(f);
System.out.println(fis.read());
} catch (FileNotFoundException e) {
e.printStackTrace();
}catch (IOException e) {
// TODO: handle exception
}catch (Exception e) {
// TODO: handle exception
}
}
}
网友评论