Source:
<code>public StyleSheet parseStyleSheet(InputSource source) throws IOException { checkInputSource(source); CSSParser parser = makeCSSParser(); CSSStyleSheet styleSheet = parser.parseStyleSheet(source); CSSRuleList rules = styleSheet.getCssRules(); int length = rules.getLength(); CSSRuleListImpl masterList = new CSSRuleListImpl(); int counter; for (counter = 0; counter < length; counter++) { CSSRule rule = rules.item(counter); if (rule.getType() != CSSRule.IMPORT_RULE) { break; } Path p = new Path(source.getURI()); IPath trim = p.removeLastSegments(1); URL url = FileLocator.resolve(new URL(trim.addTrailingSeparator().toString() + ((CSSImportRule) rule).getHref())); File testFile = new File(url.getFile()); if (!testFile.exists()) { String path = getResourcesLocatorManager().resolve(((CSSImportRule) rule).getHref()); testFile = new File(new URL(path).getFile()); if (testFile.exists()) { url = new URL(path); } } InputStream stream = url.openStream(); InputSource tempStream = new InputSource(); tempStream.setURI(url.toString()); tempStream.setByteStream(stream); parseImport = true; styleSheet = (CSSStyleSheet) this.parseStyleSheet(tempStream); parseImport = false; CSSRuleList tempRules = styleSheet.getCssRules(); for (int j = 0; j < tempRules.getLength(); j++) { masterList.add(tempRules.item(j)); } <START> stream.close(); <END> } for (int i = counter; i < length; i++) { masterList.add(rules.item(i)); } CSSStyleSheetImpl s = new CSSStyleSheetImpl(); s.setRuleList(masterList); if (documentCSS instanceof ExtendedDocumentCSS) { if (!parseImport) { documentCSS.addStyleSheet(s); } } return s; }</code><technical_language>I similar following: finally { if (stream != null) { try { stream.close(); } catch (IOException e) { // Ignore issues closing } }</technical_language>

Target:
public StyleSheet parseStyleSheet(InputSource source) throws IOException { checkInputSource(source); CSSParser parser = makeCSSParser(); CSSStyleSheet styleSheet = parser.parseStyleSheet(source); CSSRuleList rules = styleSheet.getCssRules(); int length = rules.getLength(); CSSRuleListImpl masterList = new CSSRuleListImpl(); int counter; for (counter = 0; counter < length; counter++) { CSSRule rule = rules.item(counter); if (rule.getType() != CSSRule.IMPORT_RULE) { break; } Path p = new Path(source.getURI()); IPath trim = p.removeLastSegments(1); URL url = FileLocator.resolve(new URL(trim.addTrailingSeparator().toString() + ((CSSImportRule) rule).getHref())); File testFile = new File(url.getFile()); if (!testFile.exists()) { String path = getResourcesLocatorManager().resolve(((CSSImportRule) rule).getHref()); testFile = new File(new URL(path).getFile()); if (testFile.exists()) { url = new URL(path); } } InputStream stream = null; try { stream = url.openStream(); InputSource tempStream = new InputSource(); tempStream.setURI(url.toString()); tempStream.setByteStream(stream); parseImport = true; styleSheet = (CSSStyleSheet) this.parseStyleSheet(tempStream); parseImport = false; CSSRuleList tempRules = styleSheet.getCssRules(); for (int j = 0; j < tempRules.getLength(); j++) { masterList.add(tempRules.item(j)); } } catch (IOException ex) { if (stream != null) { stream.close(); } throw ex; } } for (int i = counter; i < length; i++) { masterList.add(rules.item(i)); } CSSStyleSheetImpl s = new CSSStyleSheetImpl(); s.setRuleList(masterList); if (documentCSS instanceof ExtendedDocumentCSS) { if (!parseImport) { documentCSS.addStyleSheet(s); } } return s; }