From 1e405316d6d0114d1c3031d97286f5c32b073b64 Mon Sep 17 00:00:00 2001 From: brinn <brinn> Date: Wed, 13 Apr 2011 14:01:25 +0000 Subject: [PATCH] fix: revert last change, Closeable _is_ needed SVN: 20887 --- .../cisd/common/io/HDF5DataSetBasedContent.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/common/source/java/ch/systemsx/cisd/common/io/HDF5DataSetBasedContent.java b/common/source/java/ch/systemsx/cisd/common/io/HDF5DataSetBasedContent.java index 72baa0344d3..116c471dbc0 100644 --- a/common/source/java/ch/systemsx/cisd/common/io/HDF5DataSetBasedContent.java +++ b/common/source/java/ch/systemsx/cisd/common/io/HDF5DataSetBasedContent.java @@ -16,8 +16,11 @@ package ch.systemsx.cisd.common.io; +import java.io.Closeable; import java.io.File; import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; import ch.systemsx.cisd.base.io.AdapterIInputStreamToInputStream; import ch.systemsx.cisd.base.io.IRandomAccessFile; @@ -31,7 +34,7 @@ import ch.systemsx.cisd.hdf5.io.HDF5DataSetRandomAccessFile; * * @author Bernd Rinn */ -public class HDF5DataSetBasedContent implements IContent +public class HDF5DataSetBasedContent implements IContent, Closeable { private final File hdf5File; @@ -43,6 +46,8 @@ public class HDF5DataSetBasedContent implements IContent private final long size; + private final List<HDF5DataSetRandomAccessFile> randomAccessFiles; + public HDF5DataSetBasedContent(File hdf5File, String dataSetPath) { this.hdf5File = hdf5File; @@ -59,6 +64,7 @@ public class HDF5DataSetBasedContent implements IContent this.size = 0L; } reader.close(); + this.randomAccessFiles = new ArrayList<HDF5DataSetRandomAccessFile>(); } public String tryGetName() @@ -80,6 +86,7 @@ public class HDF5DataSetBasedContent implements IContent { final HDF5DataSetRandomAccessFile randomAccessFile = HDF5DataSetRandomAccessFile.createForReading(hdf5File, dataSetPath); + randomAccessFiles.add(randomAccessFile); return randomAccessFile; } @@ -88,4 +95,12 @@ public class HDF5DataSetBasedContent implements IContent return new AdapterIInputStreamToInputStream(getReadOnlyRandomAccessFile()); } + public void close() + { + for (HDF5DataSetRandomAccessFile raFile : randomAccessFiles) + { + raFile.close(); + } + } + } -- GitLab