[Java] 纯文本查看 复制代码
public void copyFile(String src , String dec){
FileInputStream fis=null;
BufferedInuptStream bis=null;
FileOutputStream fos=null;
BufferedOutputStream bos=null;
try {
fis=new FileInputStream(src);
fos=new FileOutputStream(dec);
bis=new BufferedInputStream(fis);
bos=new BufferedOutputStream(fos);
while ((temp=bis.read())!=-1) {
bos.write(temp);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}finally {
//增加处理流后,注意流的关闭顺序!“后打开的先关闭”
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}