java讀寫文件的模板

InputStream in = null;
OutputStream out = null;
try{
in = new FileInputStream("");
int len = 0;
byte buffer[] = new byte[1024];
out = new FileOutputStream("");
while((len = in.read(buffer))>0){
out.write(buffer, 0, len);
}
}finally{
if(in != null){
try{
in.close();
}catch (Exception e) {
e.printStackTrace();
}
}
if(out != null){
try{
out.close();
}catch (Exception e) {
e.printStackTrace();
}
}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章