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.

Re: Netcdf Array -- Java Array

----- Original Message ----- 
From: "Gabriel Taban" <gab_taban@xxxxxxxxx>
To: <netcdf-java@xxxxxxxxxxxxxxxx>
Sent: Friday, June 21, 2002 9:26 AM
Subject: Netcdf Array -- Java Array


> Hi All!
> I have a netcdf file and I would like to read one
> array (it has only one Dimension) and to put the
> numbers in a regular Java Array (int arrayName[] = new
> int[arraySize]).
> I couldn't suceed till now, so I think I need your
> help.
> Thanks,
> Gabriel


  try {
      NetcdfFile nc = new NetcdfFile(fileName);

      /* Read a variable named time */
      Variable time = nc.findVariable("time");
      Array ma2Array = time.read();

    } catch (java.io.IOException e) {
        e.printStackTrace();
    }

    // you need to know its type, else you'll get a cast exception
    int [] javaArray = (int []) ma2Array.copyTo1DJavaArray();



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