用java如何实现文件的复制功能(急) 将a.txt文件内容复制到b.txt文件中去。就100分了 知道的速度啊!@@@! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.*;public class copyfile { /** * @param args */ public static void main(String[] args) { String oldPath="c:\\a.txt"; String newPath="c:\\b.txt"; 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; //字节数 文件大小 System.out.println(bytesum); fs.write(buffer, 0, byteread); } inStream.close(); } } catch (Exception e) { System.out.println("复制单个文件操作出错"); e.printStackTrace(); } } } java调用.NET的webservice接口问题 DriverManager.getConnection的参数怎么设置啊? 关于Ejb实体Bean访问数据库的问题 每个网页都要通过action转向 交大AIC,学费半年18000元,这里有他们学校的课件,想要的点进来!!! Validate自定义BigDecimal验证问题,请高手执教 紧急求助!!!! 用什么可以做一个像IE帮助文档那样的帮助文档,谢谢! 想跳槽了,很是茫然。大家给点建议吧! 求求大家帮帮我 c/s的网络用户登陆 的 东东 需要频繁访问数据库的网页怎么处理? 两个页面怎么使用同一个 useBean
public class copyfile { /**
* @param args
*/
public static void main(String[] args) {
String oldPath="c:\\a.txt";
String newPath="c:\\b.txt";
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; //字节数 文件大小
System.out.println(bytesum);
fs.write(buffer, 0, byteread);
}
inStream.close();
}
}
catch (Exception e) {
System.out.println("复制单个文件操作出错");
e.printStackTrace();
}
} }