拷贝文件的源代码
浏览:51日期:2023-02-23
内容: //-----------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.println('Error!'); 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----------- Java, java, J2SE, j2se, J2EE, j2ee, J2ME, j2me, ejb, ejb3, JBOSS, jboss, spring, hibernate, jdo, struts, webwork, ajax, AJAX, mysql, MySQL, Oracle, Weblogic, Websphere, scjp, scjd
上一条:为什么extends是有害的(二)下一条:将特殊字符转换成HTML格式
相关文章:
热门推荐
- meta http-equiv='X-UA-Compatible' content='IE=7' 意思是将IE8用IE7进行渲染
- 1.hbuilder配置nodejs
- 2.如何在FreeBSD上用PHP实现在线添加FTP用户
- 3.golang 输出重定向:fmt Log,子进程Log,第三方库logrus的详解
- 4.JS 逻辑判断不要只知道用 if-else 和 switch条件判断(小技巧)
- 5.hbuildercss怎么用
- 6.JSP乱码解决大全
- 7.在Flash中使用ASP技术
- 8.在ASP.NET中存取图片到数据库的示例
- 9.ASP 3.0高级编程(二十五)
- 10.js完美解决IE6不支持position:fixed的bug