国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

拷貝文件的Java源代碼

2019-11-18 12:06:39
字體:
來源:轉載
供稿:網友

  //-----------Class CopyFile Begin---------
  //Class CopyFile
  //CopyRight:Writed By Yun-Fengsheng
  //Last modify time:2001-11-16
  //Method: public boolean copy(String from_filename,String to_filename)
  class CopyFile
  {
   public 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.    return(false); //if fail then return false
      }
   }
  }
  
  //Class CopyFile Example
  /*
  CopyFile copy1=new CopyFile();
  boolean copy_ok=copy1.copy("c:/hello.
jsp","c:/hello_backup.jsp");
  if(copy_ok)
  {
   out.println("拷貝成功!");
  }
  else
  {
   out.println("拷貝失敗!");
  }
  */
  //-----------Class CopyFile End-----------

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新安县| 兴和县| 五台县| 仁化县| 丽江市| 佳木斯市| 富裕县| 永州市| 碌曲县| 龙胜| 元朗区| 浦北县| 西峡县| 宁化县| 梨树县| 清新县| 岐山县| 锡林郭勒盟| 元氏县| 绥化市| 荣成市| 大余县| 岳西县| 河曲县| 思茅市| 虎林市| 凤阳县| 温宿县| 常宁市| 宁河县| 上犹县| 横山县| 阳谷县| 陆川县| 西昌市| 镇雄县| 贵州省| 多伦县| 东兰县| 明光市| 巩留县|