Code example for ProtocolException

            throw new ProtocolException("Must set doOutput");
        // you can't write after you read 
        if (sentRequest) {
            throw new ProtocolException("Can't write after you read");
        if (os != null) {
            return os;
        // they are requesting a stream to write to. This implies a POST method 
        if (method == GET) {
            method = POST;
        // If the request method is neither PUT or POST, then you're not writing 
        if (method != PUT && method != POST) {
            throw new ProtocolException("Can only write to PUT or POST");
Connect your IDE to all the code out there  Get Codota for Java