Code example for ProtocolException

0
      throw new FileNotFoundException(url.toString());
    } 
 
    InputStream result = response.getResponseBody();
    if (result == null) {
      throw new ProtocolException("No response body exists; responseCode=" + getResponseCode());
    } 
    return result;
  } 
 
  @Override public final OutputStream getOutputStream() throws IOException {
    connect(); 
 
    OutputStream out = httpEngine.getRequestBody();
    if (out == null) {
      throw new ProtocolException("method does not support a request body: " + method);
    } else if (httpEngine.hasResponse()) {
      throw new ProtocolException("cannot write request body after response has been read");
    } 
 
    return out;