public String
    readDMR()
            throws DapException
    {
        try {
            if(state != State.INITIAL)
                throw new DapException("Attempt to read DMR twice");

            byte[] dmr8 = null;

            if(requestmode == RequestMode.DMR) {
                // The whole buffer is the dmr;
                // but we do not know the length
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                int c;
                while((c = input.read()) >= 0) {
                    baos.write(c);
                }
                baos.close();
                dmr8 = baos.toByteArray();
            } else if(requestmode == RequestMode.DAP) {
                // Pull in the DMR chunk header
                if(!readHeader(input))
                    throw new DapException("Malformed chunk count");
                // Read the DMR databuffer
                dmr8 = new byte[this.chunksize];
                int red = read(dmr8, 0, this.chunksize);
                if(red < this.chunksize)
                    throw new DapException("Short chunk");
            } else
                assert false : "Internal error";

            // Convert DMR to a string
            String dmr = new String(dmr8, DapUtil.UTF8);
            // Clean it up
            dmr = dmr.trim();
            // Make sure it has trailing \r\n"
            if(dmr.endsWith("\r\n")) {
                // do nothing
            } else if(dmr.endsWith("\n"))
                dmr = dmr.substring(0,dmr.length()-2) + "\r\n";
            else
                dmr = dmr + "\r\n";

            // Figure out the endian-ness of the response
            this.remoteorder = (flags & DapUtil.CHUNK_LITTLE_ENDIAN) == 0 ? ByteOrder.BIG_ENDIAN
                    : ByteOrder.LITTLE_ENDIAN;
            this.nochecksum = (flags & DapUtil.CHUNK_NOCHECKSUM) != 0;

            // Set the state
            if((flags & DapUtil.CHUNK_ERROR) != 0)
                state = State.ERROR;
            else if((flags & DapUtil.CHUNK_END) != 0)
                state = State.END;
            else
                state = State.DATA;
            return dmr; //return the DMR

        } catch (IOException ioe) {
            throw new DapException(ioe.getMessage());
        }
    }
public String
    readDMR()
            throws DapException
    {
        try {
            if(state != State.INITIAL)
                throw new DapException("Attempt to read DMR twice");

            byte[] dmr8 = null;

            if(requestmode == RequestMode.DMR) {
                
                
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                int c;
                while((c = input.read()) >= 0) {
                    baos.write(c);
                }
                baos.close();
                dmr8 = baos.toByteArray();
            } else if(requestmode == RequestMode.DAP) {
                
                if(!readHeader(input))
                    throw new DapException("Malformed chunk count");
                
                dmr8 = new byte[this.chunksize];
                int red = read(dmr8, 0, this.chunksize);
                if(red < this.chunksize)
                    throw new DapException("Short chunk");
            } else
                assert false : "Internal error";

            
            String dmr = new String(dmr8, DapUtil.UTF8);
            
            dmr = dmr.trim();
            
            if(dmr.endsWith("\r\n")) {
                
            } else if(dmr.endsWith("\n"))
                dmr = dmr.substring(0,dmr.length()-2) + "\r\n";
            else
                dmr = dmr + "\r\n";

            
            this.remoteorder = (flags & DapUtil.CHUNK_LITTLE_ENDIAN) == 0 ? ByteOrder.BIG_ENDIAN
                    : ByteOrder.LITTLE_ENDIAN;
            this.nochecksum = (flags & DapUtil.CHUNK_NOCHECKSUM) != 0;

            
            if((flags & DapUtil.CHUNK_ERROR) != 0)
                state = State.ERROR;
            else if((flags & DapUtil.CHUNK_END) != 0)
                state = State.END;
            else
                state = State.DATA;
            return dmr; 

        } catch (IOException ioe) {
            throw new DapException(ioe.getMessage());
        }
    }
public String readDMR ( ) throws DapException { try { if ( state != State . INITIAL ) throw new DapException ( "Attempt to read DMR twice" ) ; byte [ ] dmr8 = null ; if ( requestmode == RequestMode . DMR ) { // The whole buffer is the dmr; // but we do not know the length ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; int c ; while ( ( c = input . read ( ) ) >= 0 ) { baos . write ( c ) ; } baos . close ( ) ; dmr8 = baos . toByteArray ( ) ; } else if ( requestmode == RequestMode . DAP ) { // Pull in the DMR chunk header if ( ! readHeader ( input ) ) throw new DapException ( "Malformed chunk count" ) ; // Read the DMR databuffer dmr8 = new byte [ this . chunksize ] ; int red = read ( dmr8 , 0 , this . chunksize ) ; if ( red < this . chunksize ) throw new DapException ( "Short chunk" ) ; } else assert false : "Internal error" ; // Convert DMR to a string String dmr = new String ( dmr8 , DapUtil . UTF8 ) ; // Clean it up dmr = dmr . trim ( ) ; // Make sure it has trailing \r\n" if ( dmr . endsWith ( "\r\n" ) ) { // do nothing } else if ( dmr . endsWith ( "\n" ) ) dmr = dmr . substring ( 0 , dmr . length ( ) - 2 ) + "\r\n" ; else dmr = dmr + "\r\n" ; // Figure out the endian-ness of the response this . remoteorder = ( flags & DapUtil . CHUNK_LITTLE_ENDIAN ) == 0 ? ByteOrder . BIG_ENDIAN : ByteOrder . LITTLE_ENDIAN ; this . nochecksum = ( flags & DapUtil . CHUNK_NOCHECKSUM ) != 0 ; // Set the state if ( ( flags & DapUtil . CHUNK_ERROR ) != 0 ) state = State . ERROR ; else if ( ( flags & DapUtil . CHUNK_END ) != 0 ) state = State . END ; else state = State . DATA ; return dmr ; //return the DMR } catch ( IOException ioe ) { throw new DapException ( ioe . getMessage ( ) ) ; } }
Read the DMR, trimmed.

@return the DMR as a Java String
Read the DMR trimmed .