Search code examples
javaandroiddataoutputstream

Extending dataOuputStream in android


Hi I am using custom dataOutputStream as requestStream in android. I found warning right after I created extended class.

public class RequestStream extends DataOutputStream{
/**
 * Constructs a new {@code DataOutputStream} on the {@code OutputStream}
 * {@code out}. Note that data written by this stream is not in a human
 * readable form but can be reconstructed by using a {@link DataInputStream}
 * on the resulting output.
 *
 * @param out the target stream for writing.
 */

And my all-set requestStream was like [B@6a4fc1e which should be complete request payload. (like above warning says it was not human readable)

And I got exception which I guess result from malformed dataOutputStream

java.lang.IllegalStateException: Cannot set request property after connection is made

I want to know where to put {@link DataInputStream} in code.


Solution

  • There are at least three separate questions here.

    1. Your [B@6a4fc1e is the result of calling toString(), which isn't the right thing to do with an output stream.
    2. The IllegalStateException isn't the 'result of a malformed DataOutputStream'. It is the result of exactly what it says: you tried to set a request property after the connection was made, in code you haven't posted.
    3. You don't put {@link DataInputStream} in the code. You put it in a Javadoc comment. And you already have. Unclear what you're asking.

    I don't see any actual reason to extend DataOutputStream here.