更新時(shí)間:2020-07-23 16:21:28 來源:動(dòng)力節(jié)點(diǎn) 瀏覽4094次
public?class?FileUtil?{
/**
?*?工具類關(guān)閉流
?*?可變參數(shù):?...??只能形參最后一個(gè)位置,處理方式與數(shù)組一致
?*/
public?static?void?close(Closeable?...?io){
for(Closeable?temp:io){
try?{
if?(null?!=?temp)?{
temp.close();
}
}?catch?(Exception?e)?{
}
}
}
/**
?*?使用泛型方法
?*/
public?static??void?closeAll(T?...?io){
for(Closeable?temp:io){
try?{
if?(null?!=?temp)?{
temp.close();
}
}?catch?(Exception?e)?{
}
}
}
}
以上就是動(dòng)力節(jié)點(diǎn)java培訓(xùn)機(jī)構(gòu)的小編針對“Java編程基礎(chǔ)之File類流的關(guān)閉方法”的內(nèi)容進(jìn)行的回答,希望對大家有所幫助,如有疑問,請?jiān)诰€咨詢,有專業(yè)老師隨時(shí)為你服務(wù)。
相關(guān)閱讀
初級 202925
初級 203221
初級 202629
初級 203743