代码如下:
package IO流.复制粘贴;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class InputAndOutput {
public static void main(String[] args) {
FileInputStream input=null;
FileOutputStream output=null;
try {
input=new FileInputStream("/Users/lemt/Desktop/test.pages");
output=new FileOutputStream("/Users/lemt/Desktop/copy01®.pages");
byte[] date=new byte[10000 * 1024];
int count;
while ((count = input.read(date))!=-1){
output.write(date,0,count);
}
output.flush();
} catch (IOException e) {
e.printStackTrace();
}finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (output != null) {
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}