dap4/d4servlet/src/main/java/dap4/servlet/ChunkWriter.java
public void
    cacheDMR(String dmr)
            throws IOException
    {
        if(state != State.INITIAL)
            throw new DapException("Attempt to write DMR twice");

        if(dmr == null)
            throw new DapException("Attempt to write empty DMR");

        // Strip off any trailing sequence of CR or LF.
        int len = dmr.length();
        while(len > 0) {
            char c = dmr.charAt(len - 1);
            if(c != '\r' && c != '\n') break;
            len--;
        }
        if(dmr.length() == 0)
            throw new DapException("Attempt to write empty DMR");

        dmr = dmr.substring(0, len) + DapUtil.CRLF;

        // Prepend the <?xml...?> prefix
        dmr = XMLDOCUMENTHEADER + "\n" + dmr;

        // Convert the dmr to UTF-8 and then to byte[]
        this.dmr8 = DapUtil.extract(DapUtil.UTF8.encode(dmr));

        state = State.DMR;
    }
public void
    cacheDMR(String dmr)
            throws IOException
    {
        if(state != State.INITIAL)
            throw new DapException("Attempt to write DMR twice");

        if(dmr == null)
            throw new DapException("Attempt to write empty DMR");

        // Strip off any trailing sequence of CR or LF.
        int len = dmr.length();
        while(len > 0) {
            char c = dmr.charAt(len - 1);
            if(c != '\r' && c != '\n') break;
            len--;
        }
        if(dmr.length() == 0)
            throw new DapException("Attempt to write empty DMR");

        dmr = dmr.substring(0, len) + DapUtil.CRLF;

        // Prepend the <?xml...?> prefix
        dmr = XMLDOCUMENTHEADER + "\n" + dmr;

        // Convert the dmr to UTF-8 and then to byte[]
        this.dmr8 = DapUtil.extract(DapUtil.UTF8.encode(dmr));

        state = State.DMR;
    }
Cache the DMR. What it really does is
cache the DMR and write it at the point
where it is needed; either in close(), if writing
the DMR only, or in writeChunk() if writing data as well.

@param dmr The DMR string
@throws IOException on IO related errors