1 package com.test.io;
2
3 import java.io.BufferedInputStream;
4 import java.io.BufferedOutputStream;
5 import java.io.File;
6 import java.io.FileInputStream;
7 import java.io.FileOutputStream;
8 import java.io.IOException;
9
public class TestIO {
private static int BUFFER_SIZE = 8192;
public static void main(String[] args) throws IOException {
String resourcesPath="f:/a.grd";
String targetPath="d:/a.grd";
File resourcesFile = new File(resourcesPath);
File targetFile = new File(targetPath);
BufferedInputStream input = new BufferedInputStream(new FileInputStream(resourcesFile));
BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(targetFile));
try {
byte[] buffer = new byte[BUFFER_SIZE];
int n = 0;
while (-1 != (n = input.read(buffer, 0, BUFFER_SIZE))) {
output.write(buffer, 0, n);
}
} finally {
if (input != null) {
input.close();
}
if (output != null) {
output.close();
}
}
}
}