用java怎么实现文件拷贝? 想用现成的话,有个办法,用ant的包中的copyfile task 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /** * copyÎļþ * @param oFile Ô´Îļþ * @param tFile Ä¿±êÎļþ * @param delFile ÊÇ·ñɾ³ýÔ´Îļþ * @return boolean copyÊÇ·ñ³É¹¦ * @throws FileNotFoundException Ô´ÎļþûÓз¢ÏÖʱÅ׳ö´ËÒì³£ */ public static boolean copyFile(File oFile, File tFile, boolean delFile) throws FileNotFoundException { if(!oFile.exists()) throw new FileNotFoundException(new StringBuffer("file[") .append(oFile.getName()).append("] not found!").toString()); try { byte[] b = new byte[1024]; int readLen = 0; FileInputStream fin = new FileInputStream(oFile); FileOutputStream fout = new FileOutputStream(tFile); while((readLen = fin.read(b, 0, b.length)) != -1) { fout.write(b, 0, readLen); } fin.close(); fout.close(); if(delFile) oFile.delete(); return true; } catch(IOException ex) {} return false; } 今天去一家公司的面试题 Exception in thread "main" java.lang.NullPointerException 各位大大帮忙看一下吧 新手求助:怎样从控制台读入一个整型/浮点型? 查询时做到类似于word的效果 庆祝加星,给大家几篇文章,顺便散分!! 谁有jdk1.4.1.chm的中文版????哪有下载?? ▲▲▲ 高分: 姓名 插入到表里补了几个空格,在oracle下 ▲▲▲ 请教??如果将.CLASS反编译为.JAVA文件?? JAVA的好书 我们的团队需要你!! 我适菜鸟,刚学java,能介绍经验么?关于怎样学java? 帮我看一下这个存储过程的调用哪出错了
* copyÎļþ
* @param oFile Ô´Îļþ
* @param tFile Ä¿±êÎļþ
* @param delFile ÊÇ·ñɾ³ýÔ´Îļþ
* @return boolean copyÊÇ·ñ³É¹¦
* @throws FileNotFoundException Ô´ÎļþûÓз¢ÏÖʱÅ׳ö´ËÒì³£
*/
public static boolean copyFile(File oFile,
File tFile,
boolean delFile)
throws FileNotFoundException {
if(!oFile.exists()) throw new FileNotFoundException(new StringBuffer("file[")
.append(oFile.getName()).append("] not found!").toString());
try {
byte[] b = new byte[1024];
int readLen = 0;
FileInputStream fin = new FileInputStream(oFile);
FileOutputStream fout = new FileOutputStream(tFile);
while((readLen = fin.read(b, 0, b.length)) != -1) {
fout.write(b, 0, readLen);
}
fin.close();
fout.close();
if(delFile) oFile.delete();
return true;
} catch(IOException ex) {}
return false;
}