This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
-------- Original Message -------- Subject: Re: 20000503: NetcdfFile class in netcdf Java package Date: Wed, 03 May 2000 12:47:50 -0600 From: Russ Rew <address@hidden> Organization: UCAR Unidata Program To: Yunqing Zhang <address@hidden> CC: address@hidden, address@hidden >To: address@hidden >From: Yunqing Zhang <address@hidden> >Subject: NetcdfFile class in netcdf Java package >Organization: Rutgers University >Keywords: 200005031818.e43IIOG21941 Hi Phoebe, > When I use the Java API to create and write a netcdf file, if I don't > explicitly call the close() method of my NetcdfFile object, there will > be some data loss. Although it is not a good programming practice not > to call close(), there should be no consequence whatsoever since NetcdfFile > has a finalize() method to do it automatically. But it doesn't seem to be > working in my case. Could you let me know what I miss here? I'd very > apprecaite your help. In order to make sure the finalize() method always gets called, I think you have to call the class java.lang.System method runFinalizersOnExit() with the argument true. Otherwise, there are situations in which a finalize() method may not get called. --Russ