import java.io.*;
public class AllFile {
public static void main(String[] args) throws Exception {
//若使用此方法复制文本等文件中文出现乱码,请使用上一篇文本的File方法指定编码格式为gbk可以解决.
try {
InputStream in = new FileInputStream("E:\JavaLog/logs/1.jpg");
OutputStream out = new FileOutputStream("E:\JavaLog/logs/1-copy.jpg");
byte[] bytes = new byte[1024];
int zyd = -1;
while ((zyd = in.read(bytes)) != -1) {
out.write(bytes, 0, zyd);
}
in.close();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("文件复制成功");
}
}