0
任何人都可以解釋爲什麼作者不關閉流LineNumberReader lnr?這不是必要的嗎?我是否需要關閉Android中FileReader()的流?
protected static ArrayList<Mount> getMounts() throws Exception{
LineNumberReader lnr = null;
lnr = new LineNumberReader(new FileReader("/proc/mounts"));
String line;
ArrayList<Mount> mounts = new ArrayList<Mount>();
while ((line = lnr.readLine()) != null)
{
RootTools.log(line);
String[] fields = line.split(" ");
mounts.add(new Mount(new File(fields[0]), // device
new File(fields[1]), // mountPoint
fields[2], // fstype
fields[3] // flags
));
}
InternalVariables.mounts = mounts;
if (InternalVariables.mounts != null) {
return InternalVariables.mounts;
} else {
throw new Exception();
}
}
而且,在以前的版本是:
finally {
//no need to do anything here.
}
這是一個錯誤或具體情況如何?