Skip to content

Commit 9105226

Browse files
committed
Try-with from sonar
1 parent 1678958 commit 9105226

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/align/CallableStructureAlignment.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,9 @@ private void writeXML(File outFileF, String name1, String name2, String xml)
177177
// Create file
178178
File newF = new File(outFileF, "dbsearch_" +name1+"_" + name2+".xml.gz");
179179

180-
FileOutputStream fstream = new FileOutputStream(newF);
181-
182-
GZIPOutputStream gz = new GZIPOutputStream(fstream);
183-
OutputStreamWriter writer = new OutputStreamWriter(gz);
184-
writer.write(xml);
185-
writer.close();
180+
try (OutputStreamWriter writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(newF)))) {
181+
writer.write(xml);
182+
}
186183
} catch (Exception e){//Catch exception if any
187184
logger.error("Exception: ", e);
188185
}

0 commit comments

Comments
 (0)