亚洲女人被黑人巨大进入-亚洲日本视频在线观看-亚洲AV秘片一区二区三3-亚洲欧美中文字幕乱码在线

<dfn id="uqq4w"><dl id="uqq4w"></dl></dfn>
  • <abbr id="uqq4w"></abbr>
    <center id="uqq4w"><cite id="uqq4w"></cite></center>
    ?
    徐州北大青鳥
    當前位置: 主頁 > 學在青鳥 > 編程技巧 >

    利用Java進行移動文件、剪切文件操作

    時間:2016-10-12 11:15來源:中博IT教育 作者:中博IT教育 點擊:
    思路: 1.copy 2.delete 示例: /** * 復制單個文件 * @param String oldPath 原文件路徑 如:c:/a.txt * @param String newPath 復制后路徑 如:f:/a.txt */ public static void copyFile(String oldPath, String newPath) { try

    思路:

      1.copy    
      2.delete  
       

    示例:
      /**      
                *     復制單個文件      
                *     @param     String   oldPath       原文件路徑     如:c:/a.txt      
                *     @param     String   newPath       復制后路徑     如:f:/a.txt      
                */      
      public   static   void     copyFile(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;     //字節(jié)數     文件大小      
      //System.out.println(bytesum);      
      fs.write(buffer,     0,     byteread);      
      }      
      inStream.close();      
      }      
      }      
      catch     (Exception     e)      
      {      
      //System.out.println("復制單個文件操作出錯");      
      e.printStackTrace();      
      }      
       
      }      
       
      /**      
                *     刪除單個文件      
                *     @param     String   Path               文件路徑      
                *     @param     String   filename       文件名      
                */      
      public   static   void     delFile(String     Path,     String     filename)      
      {    
                                    try{  
                                      String   path=application.getRealPath(Path);  
                                      File   fobj=new   File(path,filename);  
                                      boolean   bo_Return=fobj.delete();  
                                    }  
                                      catch     (Exception     e)      
      {      
      //System.out.println("刪除單個文件操作出錯");      
      e.printStackTrace();      
      }              
                          }

    試聽課
    (責任編輯:代碼如詩)
    ------分隔線----------------------------
    欄目列表
    推薦內容