package day09;
import java.io.*;
public class FileCopyTools {
public static void main(String[] args) throws IOException {
copyFile("E:\ReferenceCard.pdf","E:\aa.pdf");
}
public static void copyFile(String src,String des) throws IOException {
FileInputStream fis = new FileInputStream("src");
BufferedInputStream bis = new BufferedInputStream(fis);
FileOutputStream fos = new FileOutputStream("des");
BufferedOutputStream bos = new BufferedOutputStream(fos);
int temp = 0;
while ((temp = bis.read()) !=-1){
bos.write(temp);
}
bos.flush();
}
}
请教一下,谢谢!
没看懂你的操作,你的src应该是目录吧,你不是要读文件吗?你这两个地方填的应该是文件名
估计是反斜杠的问题吧,路径用反斜杠需要连续用两个,一个是转义符,或者直接用正斜杠/,用一个就可以