请问..如何实现一个文件夹的复制? 如何将一个文件夹内的所有文件复制到一个新的文件夹呀...... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 java.io.File内应该有方法可以做到 一下程序能复制文件目录和目录下的文件:package filecopy;import java.io.*;public class Filecopy { /** * @param args */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub if (args.length == 0) args = new String[] { "g:\\2", "g:\\1" }; File frompath = new File(args[0]); File topath = new File(args[1]); String[] fromlist = frompath.list(); for (int i = 0; i < fromlist.length; i++) { File fromfile = new File(frompath.getPath(), fromlist[i]); File tofile = new File(topath.getPath(), fromlist[i]); if (fromfile.isDirectory()) { tofile.mkdirs(); System.out.println( fromfile.getCanonicalPath()); main(new String[] { fromfile.getPath(), tofile.getPath() }); } else { int ch; byte[] b = new byte[256]; RandomAccessFile fin = new RandomAccessFile(fromfile, "r"); RandomAccessFile fout = new RandomAccessFile(tofile, "rw"); ch = fin.read(b); while (ch != -1) { fout.write(b); ch = fin.read(b); } fin.close(); fout.close(); } } }} 谁能说说怎样能学好java 网络广告资源 毕业设计 求平均值 一个简单的加密/解密小程序执行出错 一个URL参数显示中文乱码问题,请高手指教 请问在java中如何实现象紫光输入法一样浮在最上面的工具条? set和map问题 散分! ???(初学者问题)高手高手高高手快进,在先等 JAVA网络编程(socket),用什么工具开发?怎么配置环境? 用jBUILDER连接第一个数据库.......要疯了!!!!!!!!! 如何将16进制转换为ASCII的码的信息,特别是中文! 如何在java中实现,应用程序的右下方显示
* @param args
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
if (args.length == 0)
args = new String[] { "g:\\2", "g:\\1" };
File frompath = new File(args[0]);
File topath = new File(args[1]);
String[] fromlist = frompath.list();
for (int i = 0; i < fromlist.length; i++) {
File fromfile = new File(frompath.getPath(), fromlist[i]);
File tofile = new File(topath.getPath(), fromlist[i]);
if (fromfile.isDirectory()) {
tofile.mkdirs();
System.out.println( fromfile.getCanonicalPath());
main(new String[] { fromfile.getPath(), tofile.getPath() });
}
else {
int ch;
byte[] b = new byte[256];
RandomAccessFile fin = new RandomAccessFile(fromfile, "r");
RandomAccessFile fout = new RandomAccessFile(tofile, "rw");
ch = fin.read(b);
while (ch != -1) {
fout.write(b);
ch = fin.read(b);
}
fin.close();
fout.close();
}
} }
}