当我试图复制我得到的FileNotFoundException的.pdf文件时,我在我的framework.This中使用了这个代码,这是我在框架中编码的一部分。请帮助我任何one.If你需要任何其他信息,请问我..
public void copyFile(String dir, String file) {
try{
Debug.println("System.getProperty(\"reporthome\")"+System.getProperty("reporthome"));
File path = new File(System.getProperty("reporthome")+"\\jreports\\fileimport\\"+file);
FileInputStream fis = new FileInputStream(path);
Debug.println("dir+\"\\\\\"+file"+dir+"\\"+file);
FileOutputStream fos = new FileOutputStream(dir+"\\"+file);
int i = 0;
while( (i = fis.read()) != -1){
fos.write(i);
}
fis.close();
fos.close();
path.delete();
}catch(IOException io){
Debug.println(" Exception while copying file: "+io);
}
}发布于 2014-04-17 17:22:07
尝尝这个
public void copyFile(String dir, String file) {
try{
Debug.println("System.getProperty(\"reporthome\")"+System.getProperty("reporthome"));
File path = new File(System.getProperty("reporthome")+"\\jreports\\fileimport\\"+file);
if (path.exists()){
FileInputStream fis = new FileInputStream(path);
FileOutputStream fos = new FileOutputStream(dir+"\\"+file);
int i = 0;
while( (i = fis.read()) != -1){
fos.write(i);
}
fis.close();
fos.close();
path.delete();
} else{
Debug.println("Path doesn't exist : "+ path);
}
}catch(IOException io){
Debug.println(" Exception while copying file: "+io);
}
}发布于 2014-04-17 17:22:44
是否确定要从中复制文件的目录中有该文件?你能调试你的代码吗?我的意思是,如果您使用的是Eclipse,那么放置断点并检查代码中的这个特定异常是相当容易的。
https://stackoverflow.com/questions/23129140
复制相似问题