public void copy(String src, String dest) { InputStream is = null; OutputStream os = null; char ch[] = src.toCharArray();
// ************新添加的代码,获取文件名********** int pos = 0; for (int i = ch.length - 1; i >= 0; i--) { if (ch[i] == '\\') { if (i > pos) pos = i; } } String temp = src.substring(pos); dest = dest + temp; System.out.println("dest=" + dest);
try { is = new BufferedInputStream(new FileInputStream(src)); os = new BufferedOutputStream(new FileOutputStream(dest));
byte[] b = new byte[1024]; int len = 0; String str = null;