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.

[netcdf-java] ArrayChar problem

Hi all
   I'm having this problem: I'm trying to write a string data, so I tried
what appears in this example:
http://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg02393.html


Basically: I create an ArrayChar and then write it with nc.writeStringData,
but I get an exception: Must be of type String

if (values.getElementType() != String.class)
      throw new IllegalArgumentException("Must be ArrayObject of String ");


I took a look into the code and ArrayChar returns char:
The code for getElementType() is:

 /** Return the element class type */
  public Class getElementType() { return char.class; }

So, I tried to use ArrayObject ...

java.lang.IllegalArgumentException: variable INSI is not type CHAR
this is because of this:

 if (v2.getDataType() != DataType.CHAR)
      throw new IllegalArgumentException("variable " + varName + " is
not type CHAR");


Ok, I had the var created with dataType.String, So I changed it to Char

My question is: is this ok? should I create a var of type char then create
an ArrayObject of Strings and then write that using writeStringData?
  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: