我正在编写一段代码,返回用户输入文件名的扫描器。is never thrown in body of corresponding try statement return new Scanner(f);
我不明白为什么try块没有抛出异常,因为用户可以输入无效的文件名。编辑:将FileNotFoundException更改为NullPointerException,从而解决了第一个问题。但是,现
我有一个以源文件夹/源文件为参数的方法。我处理代码的方式是,如果源文件夹或源文件不存在,它应该抛出相应的DirectoryNotFound异常或FileNotFound异常。DirectoryNotFoundException(); throw new FileNotFoundException();
}