/*
异常文件名
*/
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;
public class YiChang {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name = null;
try {
while (true) {
name = sc.nextLine();
FileInputStream file = new FileInputStream(name);
file.close();
}
} catch (FileNotFoundException e) {
sc.close();
System.out.println(name);
} catch (IOException e) {
e.printStackTrace();
}
}
}
读取文件名,若文件名无效返回文件名并显示异常(实例)
最新推荐文章于 2021-11-01 22:48:51 发布