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

推荐订阅源

WordPress大学
WordPress大学
V
Visual Studio Blog
P
Privacy International News Feed
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
T
Threatpost
宝玉的分享
宝玉的分享
The Last Watchdog
The Last Watchdog
小众软件
小众软件
L
LINUX DO - 最新话题
C
Cisco Blogs
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
酷 壳 – CoolShell
酷 壳 – CoolShell
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Know Your Adversary
Know Your Adversary
博客园 - 叶小钗
罗磊的独立博客
V
V2EX
博客园 - Franky
P
Proofpoint News Feed
SecWiki News
SecWiki News
腾讯CDC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
PCI Perspectives
PCI Perspectives
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题

博客园 - 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();   
          }   
    }    
}
在茫茫网海中收集的两个方法,如果是您的原创,请原谅我的盗用 :(