NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi all,we use Java netCDF to analyze grib files in a tomcat Web application. Before calculation starts, our application checks if the grib file is valid for given coordinates and if is it still valid at current date. If not, try to delete not valid gribs. All works but deletion. When we try to delete the file, it looks like it is locked and we receives an exception. This is a big problem for us because, we treats a lot of files and the disk fills up fast.
We use our application in Windows 7. This is a code snippet that shows what we do:GridDataset dataset = GridDataset.open(fileGribAbsPath); // grib
boolean isValid = true; // Check date validity if (date!=null) { CalendarDateRange range = dataset.getCalendarDateRange(); CalendarDate cDate = CalendarDate.of(date); if (!range.includes(cDate)) {System.out.println("Grib File Grib not valid for date " + date);
isValid = false; } } // Check if lat,lon is inside Bounding boxif (isValid && !dataset.getBoundingBox().contains(latPoint, lonPoint)) {
System.out.println("lat,lon not in file grib range!!! "); isValid = false; } try { dataset.getNetcdfFile().close(); dataset.getNetcdfDataset().close(); dataset.close(); } catch (Exception e) { e.printStackTrace(); } return isValid;after that, if this method returns false we try to delete the file but, deletion doesn't works.
What could be wrong? Best regards Giovanni
netcdf-java
archives: