Java: Does nu.xom.Builder properly close Files? -
i using nu.xom.*
project, link found @ http://www.xom.nu/. question following part of code:
private void open() { builder = new builder(); try { document = builder.build(file); } catch (parsingexception | ioexception ex) { logger.getlogger(invoicedata.class.getname()).log(level.severe, null, ex); } }
i have unwanted file locks in program , practically checking places open file. struck me here builder.build(file file)
implement closeable
, myself not sure here whether closes file or not.
can shed light on this?
regards.
fortunately xom library open source, can take @ source code of nu.xom.builder.build(file)
:
public document build(file in) throws parsingexception, validityexception, ioexception { inputstream fin = new fileinputstream(in); // [...] string base = url.tostring(); try { document doc = build(fin, base); return doc; } { fin.close(); } }
so pass file
instance build()
method , inside method fileinputstream
opened , closed @ end.
there part after new fileinputstream(in)
not enclosed try
block. if code throws unchecked exception possible input stream isn't closed. if don't catch exception can sure, input stream closed properly.
Comments
Post a Comment