Hi!
A am trying to use the Java NetCDF library to modify the data of a variable
in an existing NetCDF4 file.
I use the 5.4.1 version of the Java library
I have version 4.7.4_2 of the netcdf C-library installed and it works
properly.
The problem I get is that when opening the existing file for writing, a NPE
is thrown.
My code looks something like this...
NetcdfFormatWriter.Builder builder =
NetcdfFormatWriter.openExisting("/temp/input.nc").setFormat(NetcdfFileFormat.NETCDF4).setNewFile(false);
NetcdfFormatWriter writer = builder.build();
But when .build() is called an exception is thrown
Exception in thread "main" java.lang.NullPointerException
at ucar.nc2.NetcdfFiles.canonicalizeUriString(NetcdfFiles.java:359)
at ucar.nc2.jni.netcdf.Nc4Iosp._open(Nc4Iosp.java:253)
at ucar.nc2.jni.netcdf.Nc4Iosp.openForWriting(Nc4Iosp.java:239)
at ucar.nc2.write.NetcdfFormatWriter.<init>(NetcdfFormatWriter.java:329)
at ucar.nc2.write.NetcdfFormatWriter.<init>(NetcdfFormatWriter.java:49)
at
ucar.nc2.write.NetcdfFormatWriter$Builder.build(NetcdfFormatWriter.java:261)
Looking at the code in the class Nc4Iosp.java
private void _open(RandomAccessFile raf, NetcdfFile ncfile, boolean
readOnly) throws IOException {
...
String location = NetcdfFiles.canonicalizeUriString(ncfile.getLocation());