io流
=============================================================================
文件拷贝
public static void main(String[] args) {
String src = "C:\\Users\\10995\\Desktop\\iotest\\bbb.txt";
String dest = "C:\\Users\\10995\\Desktop\\iotest\\aaa.txt";
copy(new File(src), new File(dest));
}
private static void copy(File srcFile, File destFile) {
try (BufferedInputStream input = new BufferedInputStream(new FileInputStream(srcFile));
BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(destFile))) {
byte[] b = new byte[1024 * 1024];//1m
int length;
while ((length = input.read(b)) > 0) {
output.write(b, 0, length);
}
} catch (IOException e) {
e.printStackTrace();
}
}
=============================================================================