欢迎来到飞鸟慕鱼博客,开始您的技术之旅!
当前位置: 首页知识笔记正文

java移动/复制文件复制/移动file

墨初 知识笔记 41阅读

public类{public static boolean Move(,String destPath){//Destination directory=new);//移动新目录布尔成功=src(new,src());返回成功;} public static boolean Move(String src File,String destPath){ //要移动的文件(或目录)=新);//目的目录=新建);//移动新目录布尔成功=(new,()));返回成功;} public static void Copy(String旧路径,String新路径){ try { int byte sum=0;int byteread=0;老了;=新);

nbsp;           if     (old())     {     
                          InputStream     inStream     =     new     (oldPath);    
                          ; fs     =     new     (newPath);   
                          byte[]     buffer     =     new     byte[1444];   
                          int     length;   
                          while     (     (byteread     =     inStream.read(buffer))     !=     -1)     {   
                                  bytesum     +=     byteread;       
                                  System.out.println(bytesum);   
                                  fs.write(buffer,     0,     byteread);   
                          }   
                          inStream.close();   
                  }   
          }   
          catch     (Exception     e)     {   
                  System.out.println( "error  ");   
                  e.printStackTrace();   
          }   
    }    
   public   static  void     Copy(; old; String     newPath)   
   {   
          try     {   
                  int     bytesum     =     0;   
                  int     byteread     =     0;   
                  //; old; =     new     );   
                  if     (old())     {     
                          InputStream     inStream     =     new     (old;
                          ; fs     =     new     (newPath);   
                          byte[]     buffer     =     new     byte[1444];   
                          while     (     (byteread     =     inStream.read(buffer))     !=     -1)     {   
                                  bytesum     +=     byteread;       
                                  System.out.println(bytesum);   
                                  fs.write(buffer,     0,     byteread);   
                          }   
                          inStream.close();   
                  }   
          }   
          catch     (Exception     e)     {   
                  System.out.println( "error  ");   
                  e.printStackTrace();   
          }   
    }    
}
在茫茫网海中收集的两个方法,如果是您的原创,请原谅我的盗用 :(

标签:
声明:无特别说明,转载请标明本文来源!