------- Forwarded Message
To: "'address@hidden'" <address@hidden>
From: "Nguyen, Cu (NIH/NCI)" <address@hidden>
Subject: Java NetCDF Newbie - Write/Read Array Of Strings
Organization: NIH
Keywords: 200403221657.i2MGvJrV029768 netCDF Java
Hi All,
I am a new Java NetCDF user trying to create an array of strings on
NetCDF using some examples that
I found in the NetCDF FAQ. The NetCDF file created successfully but It only
stores the last string in the array.
Please take a look at the following code and let me know what I am doing
wrong. ( I also tried to set Range between
1 and 2 and ArrayChar.D2 without any success).
nSets=4;
testName = new String[nSets];
testName[0]="name1";
testName[1]="name2";
testName[2]="name3";
testName[3]="name4";
NetcdfFileWriteable ncFile = new NetcdfFileWriteable();
ncFile.setName(filename);
Dimension t1Dim = ncFile.addDimension("example", nSets);
Dimension[] dim1 = new Dimension[1];
dim1[0] = t1Dim;
ncFile.addVariable("testName", char.class, dim1);
ncFile.create();
// --------------------------------
ArrayChar ac = new ArrayChar.D1(5);
for(int y = 0; y < nSets; y++) {
ac.setString(testName[y]);
}
ncFile.write("testName", new int[1],ac);
/* ncFile.write("testName", ac);*/
ncFile.close();
Thanks,
CNguyen
--
NOTE: All email exchanges with Unidata User Support are recorded in the
Unidata inquiry tracking system and then made publically available
through the web. If you do not want to have your interactions made
available in this way, you must let us know in each email you send to us.
------- End of Forwarded Message