How to create netcdfFile without location ? JAVA

71 Views Asked by At

I am trying to convert a product into netcdf object. i am using unidata library.

What i want to do is return a netcdf object into xml response.

In fact, I create NetcdfFileWriter with method

createNew()

. But a location is mandatory. I do not want to save the file somewhere because what i want is return it into xml response.

My method is now returning NetcdfFile created with the method above. But i still have a file on my disk that i do not want.

Have you an idea ?

1

There are 1 best solutions below

1
On

It is not possible to create a NetcdfFile object in memory with the netCDF-Java library, because there's no in-memory implementation of the underlying RandomAccessFile. You could use a temp file as the location, e.g. java.io.File.createTempFile().