protected Object convert ( byte [ ] barray , DataType dataType , int nelems , int byteOrder ) { if ( dataType == DataType . BYTE ) { return barray ; } if ( dataType == DataType . CHAR ) { return IospHelper . convertByteToChar ( barray ) ; } ByteBuffer bbuff = ByteBuffer . wrap ( barray ) ; if ( byteOrder >= 0 ) bbuff . order ( byteOrder == ucar . unidata . io . RandomAccessFile . LITTLE_ENDIAN ? ByteOrder . LITTLE_ENDIAN : ByteOrder . BIG_ENDIAN ) ; if ( dataType == DataType . SHORT ) { ShortBuffer tbuff = bbuff . asShortBuffer ( ) ; short [ ] pa = new short [ nelems ] ; tbuff . get ( pa ) ; return pa ; } else if ( dataType == DataType . INT ) { IntBuffer tbuff = bbuff . asIntBuffer ( ) ; int [ ] pa = new int [ nelems ] ; tbuff . get ( pa ) ; return pa ; } else if ( dataType == DataType . FLOAT ) { FloatBuffer tbuff = bbuff . asFloatBuffer ( ) ; float [ ] pa = new float [ nelems ] ; tbuff . get ( pa ) ; return pa ; } else if ( dataType == DataType . DOUBLE ) { DoubleBuffer tbuff = bbuff . asDoubleBuffer ( ) ; double [ ] pa = new double [ nelems ] ; tbuff . get ( pa ) ; return pa ; } throw new IllegalStateException ( ) ; }
this converts a byte array to another primitive array