`
wushipan_easy
  • 浏览: 3873 次
  • 性别: Icon_minigender_1
  • 来自: 河南
社区版块
存档分类
最新评论

测试1

 
阅读更多
public static boolean copy(String file1, String file2) {  
        try // must try and catch,otherwide will compile error  
        {  
            // instance the File as file_in and file_out  
            java.io.File file_in = new java.io.File(file1);  
            java.io.File file_out = new java.io.File(file2);  
            FileInputStream in1 = new FileInputStream(file_in);  
            FileOutputStream out1 = new FileOutputStream(file_out);  
            byte[] bytes = new byte[1024];  
            int c;  
            while ((c = in1.read(bytes)) != -1)  
                out1.write(bytes, 0, c);  
            in1.close();  
            out1.close();  
            return (true); // if success then return true  
        } catch (Exception e) {  
            System.out.println("Error!");  
            return (false); // if fail then return false  
        }  
    }

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics