java.io.FileNotFoundException系统找不到指定的路径 [英] java.io.FileNotFoundException The system cannot find the path specified
本文介绍了java.io.FileNotFoundException系统找不到指定的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个定时器设置来调用一个包含pdf生成代码的类。我已经设置了需要保存的文件路径..但它显示异常为java.io.FileNotFoundException:D:\(The系统找不到指定的路径。。我不知道错误在哪里..
I have a timer set to invoke a class that contains pdf generating codes.I have set the file path where it needs to be saved..but it is showing exception as java.io.FileNotFoundException : D:\ (The system cannot find the path specified) .I dont know where is the mistake..
这是我的代码..
try {
OutputStream file = new FileOutputStream(new File("D://"));
Document document = new Document();
//PDF generating code..
document.add(list); //In the new page we are going to add list
document.close();
file.close();
System.out.println("Pdf created successfully..");
} catch (Exception e) {
e.printStackTrace();
}
推荐答案
您还没有提供该文件name因此你得到那个例外,使用下面的代码
You have not provided the file name so you get that exception,use below code
OutputStream file = new FileOutputStream(new File("D://timer.pdf"));
请参阅doc 这里
这篇关于java.io.FileNotFoundException系统找不到指定的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文