惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
量子位
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
Google DeepMind News
Google DeepMind News
小众软件
小众软件
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
雷峰网
雷峰网
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - Notus|南色的风

asp.net用url重写URLReWriter实现任意二级域名(续) selenium cant start a new browser(ie7):java.lang.StringIndexOutOfBoundsException: String index out of range: -1 修改sql server2005的系统时间 conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. eclipse输出jar的利器 java调用c#写的webservice java的Date.getTime()转换成C#的Datetime.ticks - Notus|南色的风 - 博客园 我的新博客 关于小凡 关于迷笛音乐节的重大通知-_- 给我一点自由...... 4月份的歌 都说了,一切都会过去 everything Will Flow Take It Away song2 【Ireland On-Line】霍利尔:裁判毁了枪手 【每日邮报】利物浦对阵阿森纳能走出牢狱要谢天谢地谢Peter Turn into
java移动/复制文件 copy/move file
Notus|南色的风 · 2008-08-06 · via 博客园 - Notus|南色的风

public class FileAccess
{

 public static boolean Move(File srcFile, String destPath)
 {
        // Destination directory
        File dir = new File(destPath);
      
        // Move file to new directory
        boolean success = srcFile.renameTo(new File(dir, srcFile.getName()));
      
        return success;
    }
 
 public static boolean Move(String srcFile, String destPath)
 {
        // File (or directory) to be moved
        File file = new File(srcFile);
      
        // Destination directory
        File dir = new File(destPath);
      
        // Move file to new directory
        boolean success = file.renameTo(new File(dir, file.getName()));
      
        return success;
    }
 
 public  static   void     Copy(String     oldPath,     String     newPath)   
   {   
          try     {   
                  int     bytesum     =     0;   
                  int     byteread     =     0;   
                  File     oldfile     =     new     File(oldPath);   
                  if     (oldfile.exists())     {     
                          InputStream     inStream     =     new     FileInputStream(oldPath);    
                          FileOutputStream     fs     =     new     FileOutputStream(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(File     oldfile,     String     newPath)   
   {   
          try     {   
                  int     bytesum     =     0;   
                  int     byteread     =     0;   
                  //File     oldfile     =     new     File(oldPath);   
                  if     (oldfile.exists())     {     
                          InputStream     inStream     =     new     FileInputStream(oldfile);    
                          FileOutputStream     fs     =     new     FileOutputStream(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();   
          }   
    }    
}
在茫茫网海中收集的两个方法,如果是您的原创,请原谅我的盗用 :(