get file content

来源:互联网 发布:mac book pro 15寸 编辑:程序博客网 时间:2024/05/01 15:46

private String getFileContent(String url) {
  byte[] responseBody = null;
  try {
   HttpClient client = new HttpClient();
   if (PropertyReader.getInstance().getPxy_usage().trim().equals(
     "true")) {
    HostConfiguration hConf = client.getHostConfiguration();
    String proxyServer = PropertyReader.getInstance()
      .getServerName().trim();
    String proxyPort = PropertyReader.getInstance().getPort();
    int port = new Integer(proxyPort).intValue();
    hConf.setProxy(proxyServer, port);
   }
   HttpMethod method = new GetMethod(url);
   int statusCode = client.executeMethod(method);
   if (statusCode != HttpStatus.SC_OK) {
   }
   responseBody = method.getResponseBody();

   method.releaseConnection();

   return new String(responseBody, "shift_jis");
  } catch (IOException ioe) {
  }
  // content code end

 }

原创粉丝点击