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 ----- From: "Gabriel Taban" <address@hidden> To: <address@hidden> 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();