cdm/src/main/java/ucar/atd/dorade/DoradeDescriptor.java
protected byte[] readDescriptor(RandomAccessFile file,
                                  boolean littleEndianData,
                                  String expectedName)
          throws DescriptorException {

    this.file = file;
    this.littleEndianData = littleEndianData;
    this.expectedName = expectedName;
    verbose = getDefaultVerboseState(expectedName);

    byte[] data;

    try {
      //
      // find the next descriptor with our expected name
      //
      findNext(file);

      //
      // keep track of the start of this descriptor
      //
      long startpos = file.getFilePointer();

      //
      // get the name and descriptor size
      //
      byte[] header = new byte[8];
      file.readFully(header);
      descName = new String(header, 0, 4, CDM.utf8Charset);
      int size = grabInt(header, 4);

      //
      // now back up to the start of the descriptor and read the entire
      // thing into a byte array
      //
      file.seek(startpos);

      data = new byte[size];
      file.readFully(data);
    } catch (java.io.IOException ex) {
      throw new DescriptorException(ex);
    }

    //
    // now check the name we got against the expected name
    //
    if (!descName.equals(expectedName))
      throw new DescriptorException("Got descriptor name '" + descName +
              "' when expecting name '" +
              expectedName + "'");

    return data;
  }
protected byte[] readDescriptor(RandomAccessFile file,
                                  boolean littleEndianData,
                                  String expectedName)
          throws DescriptorException {

    this.file = file;
    this.littleEndianData = littleEndianData;
    this.expectedName = expectedName;
    verbose = getDefaultVerboseState(expectedName);

    byte[] data;

    try {
      //
      // find the next descriptor with our expected name
      //
      findNext(file);

      //
      // keep track of the start of this descriptor
      //
      long startpos = file.getFilePointer();

      //
      // get the name and descriptor size
      //
      byte[] header = new byte[8];
      file.readFully(header);
      descName = new String(header, 0, 4, CDM.utf8Charset);
      int size = grabInt(header, 4);

      //
      // now back up to the start of the descriptor and read the entire
      // thing into a byte array
      //
      file.seek(startpos);

      data = new byte[size];
      file.readFully(data);
    } catch (java.io.IOException ex) {
      throw new DescriptorException(ex);
    }

    //
    // now check the name we got against the expected name
    //
    if (!descName.equals(expectedName))
      throw new DescriptorException("Got descriptor name '" + descName +
              "' when expecting name '" +
              expectedName + "'");

    return data;
  }
protected byte [ ] readDescriptor ( RandomAccessFile file , boolean littleEndianData , String expectedName ) throws DescriptorException { this . file = file ; this . littleEndianData = littleEndianData ; this . expectedName = expectedName ; verbose = getDefaultVerboseState ( expectedName ) ; byte [ ] data ; try { // // find the next descriptor with our expected name // findNext ( file ) ; // // keep track of the start of this descriptor // long startpos = file . getFilePointer ( ) ; // // get the name and descriptor size // byte [ ] header = new byte [ 8 ] ; file . readFully ( header ) ; descName = new String ( header , 0 , 4 , CDM . utf8Charset ) ; int size = grabInt ( header , 4 ) ; // // now back up to the start of the descriptor and read the entire // thing into a byte array // file . seek ( startpos ) ; data = new byte [ size ] ; file . readFully ( data ) ; } catch ( java . io . IOException ex ) { throw new DescriptorException ( ex ) ; } // // now check the name we got against the expected name // if ( ! descName . equals ( expectedName ) ) throw new DescriptorException ( "Got descriptor name '" + descName + "' when expecting name '" + expectedName + "'" ) ; return data ; }
Read and set the descriptor name, size, and endianness, and return the
entire contents of the descriptor (including the name and size) as a
byte array.  The file position will be left at the beginning of the next
descriptor (or at the end of file).

@param file             the DORADE sweepfile, positioned at the beginning of a
descriptor
@param littleEndianData set to true iff the file contains little-endian
data
@param expectedName     the expected name for the descriptor being read
@throws DescriptorException for file read errors, descriptor name
mismatch, etc.
Read and set the descriptor name size and endianness and return the entire contents of the descriptor ( including the name and size ) as a byte array . The file position will be left at the beginning of the next descriptor ( or at the end of file ) .