Use try-with-resource.
This commit is contained in:
parent
080a393b4f
commit
057ab56f3e
|
@ -261,11 +261,8 @@ public abstract class AbstractObjectTest extends BulkTest {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected void writeExternalFormToDisk(final Serializable o, final String path) throws IOException {
|
protected void writeExternalFormToDisk(final Serializable o, final String path) throws IOException {
|
||||||
final FileOutputStream fileStream = new FileOutputStream(path);
|
try (FileOutputStream fileStream = new FileOutputStream(path)) {
|
||||||
try {
|
|
||||||
writeExternalFormToStream(o, fileStream);
|
writeExternalFormToStream(o, fileStream);
|
||||||
} finally {
|
|
||||||
fileStream.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,11 +291,8 @@ public abstract class AbstractObjectTest extends BulkTest {
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
protected Object readExternalFormFromDisk(final String path) throws IOException, ClassNotFoundException {
|
protected Object readExternalFormFromDisk(final String path) throws IOException, ClassNotFoundException {
|
||||||
final FileInputStream stream = new FileInputStream(path);
|
try (FileInputStream stream = new FileInputStream(path)) {
|
||||||
try {
|
|
||||||
return readExternalFormFromStream(stream);
|
return readExternalFormFromStream(stream);
|
||||||
} finally {
|
|
||||||
stream.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue