[netcdf-java] Files locked after open

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 box
if (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



  • 2013 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: