java.net.ProtocolException.printStackTrace()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中java.net.ProtocolException.printStackTrace()方法的一些代码示例,展示了ProtocolException.printStackTrace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ProtocolException.printStackTrace()方法的具体详情如下:
包路径:java.net.ProtocolException
类名称:ProtocolException
方法名:printStackTrace

ProtocolException.printStackTrace介绍

暂无

代码示例

代码示例来源:origin: Leaking/WeGit

public HttpKnife option(String url) {
  try {
    openConnection(new URL(url));
    connection.setRequestMethod(Method.OPTIONS);
    return this;
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (MalformedURLException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: Leaking/WeGit

public HttpKnife put(String url) {
  try {
    openConnection(new URL(url));
    connection.setRequestMethod(Method.PUT);
    connection.setDoOutput(true);
  } catch (MalformedURLException e) {
    e.printStackTrace();
  } catch (ProtocolException e) {
    e.printStackTrace();
  }
  return this;
}

代码示例来源:origin: Leaking/WeGit

public HttpKnife head(String url) {
  try {
    openConnection(new URL(url));
    connection.setRequestMethod(Method.HEAD);
    return this;
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (MalformedURLException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: Leaking/WeGit

public HttpKnife trace(String url) {
  try {
    openConnection(new URL(url));
    connection.setRequestMethod(Method.TRACE);
    return this;
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (MalformedURLException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: Leaking/WeGit

public HttpKnife patch(String url) {
  try {
    openConnection(new URL(url));
    connection.setRequestMethod(Method.PATCH);
    return this;
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (MalformedURLException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: Leaking/WeGit

public HttpKnife delete(String url) {
  try {
    System.out.println("delete request : " + url);
    openConnection(new URL(url));
    connection.setRequestMethod(Method.DELETE);
    return this;
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (MalformedURLException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: ShuaiJunlan/Autumn

private static HttpURLConnection doHttp(String url, int timeout, String method, boolean doinput, boolean dooutput) {
  HttpURLConnection con = null;
  try {
    URL url1 = new URL(url);
    con = (HttpURLConnection) url1.openConnection();
    con.setReadTimeout(timeout);                                                        //将读超时设置为指定的超时,以毫秒为单位。用一个非零值指定在建立到资源的连接后从 Input 流读入时的超时时间。如果在数据可读取之前超时期满,则会引发一个 java.net.SocketTimeoutException。
    con.setDoInput(doinput);                                                            //指示应用程序要从 URL 连接读取数据。
    con.setDoOutput(dooutput);
    con.setRequestMethod(method);
  } catch (MalformedURLException e) {
    e.printStackTrace();
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return con;
}

代码示例来源:origin: Leaking/WeGit

/**
 * 不带参数的get请求
 * 
 * @param url
 * @return
 */
public HttpKnife get(String url) {
  try {
    openConnection(new URL(url));
    connection.setRequestMethod(Method.GET);
    return this;
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (MalformedURLException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: payu-intrepos/Android-SDK-Sample-App

@Override
protected Void doInBackground(Void... params) {
  try {
    //TODO Replace below url with your server side file url.
    URL url = new URL("https://payu.herokuapp.com/delete_merchant_hash");
    byte[] postParamsByte = postParams.getBytes("UTF-8");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("POST");
    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    conn.setRequestProperty("Content-Length", String.valueOf(postParamsByte.length));
    conn.setDoOutput(true);
    conn.getOutputStream().write(postParamsByte);
  } catch (MalformedURLException e) {
    e.printStackTrace();
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: Leaking/WeGit

/**
 * post请求初始化
 * 
 * @param url
 * @throws ProtocolException
 * @throws MalformedURLException
 */
public HttpKnife post(String url) {
  try {
    openConnection(new URL(url));
    connection.setRequestMethod(Method.POST);
    connection.setDoOutput(true);
  } catch (MalformedURLException e) {
    e.printStackTrace();
  } catch (ProtocolException e) {
    e.printStackTrace();
  }
  return this;
}

代码示例来源:origin: ShuaiJunlan/Autumn

public static String doGet(String url) {
  try {
    HttpURLConnection con = doHttp(url, 500000, "GET", true, false);
    if (con.getResponseCode() == 200)                                               //当请求成功时,接收数据(状态码“200”为成功连接的意思“ok”)
    {
      InputStream is = con.getInputStream();
      str = formatIsToString(is);
    }
  } catch (MalformedURLException e) {
    e.printStackTrace();
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  } catch (Exception e) {
    e.printStackTrace();
  }
  return str;
}

代码示例来源:origin: zhangyd-c/OneBlog

/**
 * 获取网站的favicon图标大小
 *
 * @param faviocnUrl
 *         favicon地址
 * @return favicon图标大小
 */
private static int getFaviconSize(String faviocnUrl) {
  int contentLength = 0;
  try {
    final URL url = new URL(faviocnUrl);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod(HttpMethod.GET.name());
    connection.setDoOutput(true);
    // 必须设置false,否则会自动redirect到Location的地址
    connection.setInstanceFollowRedirects(false);
    contentLength = connection.getContentLength();
    log.debug("Favicon size : {}", contentLength);
  } catch (MalformedURLException e) {
    e.printStackTrace();
    log.error("请求地址不对", e);
  } catch (ProtocolException e) {
    e.printStackTrace();
    log.error("请求地址协议异常", e);
  } catch (IOException e) {
    e.printStackTrace();
    log.error("数据传输异常", e);
  }
  return contentLength;
}

代码示例来源:origin: payu-intrepos/Android-SDK-Sample-App

e.printStackTrace();
} catch (ProtocolException e) {
  e.printStackTrace();
} catch (UnsupportedEncodingException e) {
  e.printStackTrace();

代码示例来源:origin: com.vmware/vijava

} catch (ProtocolException e) 
  e.printStackTrace();

代码示例来源:origin: com.github.g-chenning/jdbc-yml-quick-util

return null;
} catch (ProtocolException e) {
  e.printStackTrace();
  return null;
} catch (IOException e) {

代码示例来源:origin: ShuaiJunlan/Autumn

public static String doPost(String url, Map<String, String> params) {
  try {
    HttpURLConnection con = doHttp(url, 500000, "POST", true, true);                                                          //指示应用程序要将数据写入 URL 连接。
    String content = getContent(params);                                            //解析参数(请求的内容)
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");    //设置内容
    con.setRequestProperty("Content-Length", content.length() + "");                //设置内容长度
    OutputStream os = con.getOutputStream();
    os.write(content.getBytes("utf-8"));                                            //发送参数内容
    os.flush();
    os.close();
    if (con.getResponseCode() == 200) {
      str = formatIsToString(con.getInputStream());
    }
  } catch (MalformedURLException e) {
    e.printStackTrace();
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  } catch (Exception e) {
    e.printStackTrace();
  }
  return str;
}

代码示例来源:origin: payu-intrepos/Android-SDK-Sample-App

e.printStackTrace();
} catch (ProtocolException e) {
  e.printStackTrace();
} catch (UnsupportedEncodingException e) {
  e.printStackTrace();

代码示例来源:origin: Leaking/WeGit

public HttpKnife json(JSONObject json) {
  try {
    String contentType = getBodyContentType(CONTENT_TYPE_JSON,
        getParamsEncoding());
    header(RequestHeader.CONTENT_TYPE, contentType);
    byte[] body = json.toString().getBytes(getParamsEncoding());
    DataOutputStream out = new DataOutputStream(openOutput());
    out.write(body);
  } catch (ProtocolException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return this;
}

代码示例来源:origin: com.qcloud/cos_api

System.out.println("Service returned response code " + responseCode);
} catch (ProtocolException e) {
  e.printStackTrace();
} catch (IOException e) {
  e.printStackTrace();

代码示例来源:origin: tencentyun/cos-java-sdk-v5

System.out.println("Service returned response code " + responseCode);
} catch (ProtocolException e) {
  e.printStackTrace();
} catch (IOException e) {
  e.printStackTrace();

相关文章