`
jirang_team
  • 浏览: 5034 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

复制文件

 
阅读更多
/**
   *   复制文件,将sourcefile文件复制到targetfile
   *  
   *   @param   sourceFile
   *   @param   targetFile
   */
private   void   copy(String   sourceFile,   String   targetFile)   {
FileInputStream   input   =   null;
FileOutputStream   output   =   null;
try   {
input   =   new   FileInputStream(sourceFile);
output   =   new   FileOutputStream(targetFile);
byte[]   b   =   new   byte[1024   *   5];
int   len;
while   ((len   =   input.read(b))   !=   -1)   {
output.write(b,   0,   len);
}
output.flush();
output.close();
input.close();

}   catch   (Exception   e)   {
System.out.println("文件无法读取!");

}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics