public class Demo {
public static void main(String[] args) {
InputStream in = null;
try {
in = new FileInputStream("D:\\sogou.exe");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
OutputStream out = null;
try {
out = new FileOutputStream("sogou.exe");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] b= new byte[1024];
int len = 0;
try {
while((len=in.read(b))!= -1){
out.write(b,0,len);
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if(in != null){
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if(out != null){
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("复制完毕!");
}
}
|
|