首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FileNotFoundException错误

FileNotFoundException错误
EN

Stack Overflow用户
提问于 2014-04-17 17:17:31
回答 2查看 37关注 0票数 0

当我试图复制我得到的FileNotFoundException的.pdf文件时,我在我的framework.This中使用了这个代码,这是我在框架中编码的一部分。请帮助我任何one.If你需要任何其他信息,请问我..

代码语言:javascript
复制
 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);
        }

     }
EN

回答 2

Stack Overflow用户

发布于 2014-04-17 17:22:07

尝尝这个

代码语言:javascript
复制
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);
    }

 }
票数 0
EN

Stack Overflow用户

发布于 2014-04-17 17:22:44

是否确定要从中复制文件的目录中有该文件?你能调试你的代码吗?我的意思是,如果您使用的是Eclipse,那么放置断点并检查代码中的这个特定异常是相当容易的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23129140

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档