File tree Expand file tree Collapse file tree
src/main/java/loci/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,24 +122,10 @@ public IniList parseINI(String path, Class<?> c)
122122 public IniList parseINI (File file )
123123 throws IOException
124124 {
125- FileInputStream fis = null ;
126- InputStreamReader isr = null ;
127- BufferedReader br = null ;
128- try {
129- fis = new FileInputStream (file );
130- isr = new InputStreamReader (fis , Constants .ENCODING );
131- br = new BufferedReader (isr );
125+ try (FileInputStream fis = new FileInputStream (file );
126+ InputStreamReader isr = new InputStreamReader (fis , Constants .ENCODING );
127+ BufferedReader br = new BufferedReader (isr )) {
132128 return parseINI (br );
133- } finally {
134- if (br != null ) {
135- br .close ();
136- }
137- if (isr != null ) {
138- isr .close ();
139- }
140- if (fis != null ) {
141- fis .close ();
142- }
143129 }
144130 }
145131
Original file line number Diff line number Diff line change @@ -189,12 +189,9 @@ public static Document createDocument() {
189189 public static Document parseDOM (File file )
190190 throws ParserConfigurationException , SAXException , IOException
191191 {
192- InputStream is = new FileInputStream (file );
193- try {
192+ try (InputStream is = new FileInputStream (file )) {
194193 Document doc = parseDOM (is );
195194 return doc ;
196- } finally {
197- is .close ();
198195 }
199196 }
200197
@@ -211,12 +208,9 @@ public static Document parseDOM(String xml)
211208 throws ParserConfigurationException , SAXException , IOException
212209 {
213210 byte [] bytes = xml .getBytes (Constants .ENCODING );
214- InputStream is = new ByteArrayInputStream (bytes );
215- try {
211+ try (InputStream is = new ByteArrayInputStream (bytes )) {
216212 Document doc = parseDOM (is );
217213 return doc ;
218- } finally {
219- is .close ();
220214 }
221215 }
222216
You can’t perform that action at this time.
0 commit comments