Closing of the IFormatReader object.
 Posted: Fri Apr 02, 2010 7:27 am
Posted: Fri Apr 02, 2010 7:27 amThe following code opens a file using IFormatReader, closes all the objects and tries to delete the file.
The delete file will not work. I think its because of line 135 (Location.getHandle(id);) in ImageReader in the public IFormatReader getReader(String id) method. It returns an IRandomAccess which needs to be closed. When i replace that code with the following it seems to work fine.
I dont know if this change has any side effects furthur on. Could someone comment on the same? If its a valid issue, maybe it could be fixed next release.
~Thanks
			- Code: Select all
- /* open image reader */
 ImageReader imgReader = new ImageReader();
 IFormatReader formatReader = imgReader.getReader("file.tif");
 formatReader.setId("file.tif");
 BufferedImageReader bufferedImageReader = new BufferedImageReader(formatReader);
 BufferedImage buffImage = bufferedImageReader.openThumbImage(0);
 /* close image reader */
 imgReader.close();
 imgReader = null;
 formatReader.close();
 formatReader = null;
 /* delete file */
 File filenameObj = new File("file.tif");
 boolean boolFile = filenameObj.delete();
The delete file will not work. I think its because of line 135 (Location.getHandle(id);) in ImageReader in the public IFormatReader getReader(String id) method. It returns an IRandomAccess which needs to be closed. When i replace that code with the following it seems to work fine.
- Code: Select all
- IRandomAccess canReadID = Location.getHandle(id);
 canReadID.close();
I dont know if this change has any side effects furthur on. Could someone comment on the same? If its a valid issue, maybe it could be fixed next release.
~Thanks