package kgc.com;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyDemo {
public static void main(String[] args) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream("bdqn.txt");
fos = new FileOutputStream("bdqncopy.txt");
int result = -1;
String info = "";
System.out.println("能够读取到的字节数:"+fis.available());
while((result = fis.read())!=-1) {
info += (char)result;
//System.out.print((char)result);
}
System.out.println("读取完毕,准备复制");
byte[] bytes = info.getBytes();
fos.write(bytes, 0, bytes.length);
System.out.println("复制完毕,请刷新工程查看文件");
fos.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
if(fos!=null) {
fos.close();
}
if(fis!=null) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}