Source:
<code>protected void loadPersonFile() throws IOException { final String METHOD_NAME = "loadPersonFile()"; File personnelFile = FileDialogs.openPersonnel(frame).orElse(null); if (personnelFile != null) { <START> InputStream is = new FileInputStream(personnelFile); <END> MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.INFO, "Starting load of personnel file from XML..."); Document xmlDoc = null; try { DocumentBuilder db = MekHqXmlUtil.newSafeDocumentBuilder(); xmlDoc = db.parse(is); is.close(); } catch (Exception ex) { MekHQ.getLogger().error(getClass(), METHOD_NAME, ex); } Element personnelEle = xmlDoc.getDocumentElement(); NodeList nl = personnelEle.getChildNodes(); personnelEle.normalize(); Version version = new Version(personnelEle.getAttribute("version")); for (int x = 0; x < nl.getLength(); x++) { Node wn2 = nl.item(x); if (wn2.getNodeType() != Node.ELEMENT_NODE) { continue; } if (!wn2.getNodeName().equalsIgnoreCase("person")) { MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.ERROR, "Unknown node type not loaded in Personnel nodes: " + wn2.getNodeName()); continue; } Person p = Person.generateInstanceFromXML(wn2, getCampaign(), version); if (getCampaign().getPerson(p.getId()) != null && getCampaign().getPerson(p.getId()).getFullName() .equals(p.getFullName())) { MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.ERROR, "ERROR: Cannot load person who exists, ignoring. (Name: " + p.getFullName() + ")"); p = null; } if (p != null) { getCampaign().addPersonWithoutId(p, true); p.setUnitId(null); p.clearTechUnitIDs(); } } MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.INFO, "Finished load of personnel file"); } }</code><technical_language>try-with-resources? (the in this file)</technical_language>

Target:
protected void loadPersonFile() { final String METHOD_NAME = "loadPersonFile()"; File personnelFile = FileDialogs.openPersonnel(frame).orElse(null); if (personnelFile != null) { MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.INFO, "Starting load of personnel file from XML..."); Document xmlDoc = null; try (InputStream is = new FileInputStream(personnelFile)) { DocumentBuilder db = MekHqXmlUtil.newSafeDocumentBuilder(); xmlDoc = db.parse(is); } catch (Exception ex) { MekHQ.getLogger().error(getClass(), METHOD_NAME, ex); } Element personnelEle = xmlDoc.getDocumentElement(); NodeList nl = personnelEle.getChildNodes(); personnelEle.normalize(); Version version = new Version(personnelEle.getAttribute("version")); for (int x = 0; x < nl.getLength(); x++) { Node wn2 = nl.item(x); if (wn2.getNodeType() != Node.ELEMENT_NODE) { continue; } if (!wn2.getNodeName().equalsIgnoreCase("person")) { MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.ERROR, "Unknown node type not loaded in Personnel nodes: " + wn2.getNodeName()); continue; } Person p = Person.generateInstanceFromXML(wn2, getCampaign(), version); if (getCampaign().getPerson(p.getId()) != null && getCampaign().getPerson(p.getId()).getFullName() .equals(p.getFullName())) { MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.ERROR, "ERROR: Cannot load person who exists, ignoring. (Name: " + p.getFullName() + ")"); p = null; } if (p != null) { getCampaign().addPersonWithoutId(p, true); p.setUnitId(null); p.clearTechUnitIDs(); } } MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.INFO, "Finished load of personnel file"); } }