Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.

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: