Code example for ProtocolException

0
    } 
 
    @Override 
    public OutputStream getOutputStream() throws IOException {
        if (!doOutput) {
            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;
        }