Пример #1
0
  public static String getURLContent(final String uri) {

    try {
      StringBuffer content = new StringBuffer();
      HttpUtil.getURLContent(uri, content);
      return content.toString();
    } catch (Exception e) {
      // TODO: handle this error
      Logger.error(
          "org.pentaho.platform.util.web.HttpUtil",
          Messages.getInstance().getErrorString("HttpUtil.ERROR_0001_URL_ERROR", e.getMessage()),
          e); //$NON-NLS-1$ //$NON-NLS-2$
      return null;
    }
  }
Пример #2
0
  public static Reader getURLReader(final String uri) {

    try {
      URL url = new URL(uri);
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      connection.connect();
      InputStream in = connection.getInputStream();
      return new InputStreamReader(in);
    } catch (Exception e) {
      // TODO: handle this error
      Logger.error(
          HttpUtil.class.getName(),
          Messages.getInstance().getErrorString("HttpUtil.ERROR_0001_URL_ERROR", e.getMessage()),
          e); //$NON-NLS-1$
      return null;
    }
  }
Пример #3
0
  public static InputStream getURLInputStream(final String uri) {

    try {
      URL url = new URL(uri);
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      connection.connect();
      InputStream in = connection.getInputStream();
      return in;
    } catch (Exception e) {
      // TODO: handle this error
      Logger.error(
          "org.pentaho.platform.util.web.HttpUtil",
          Messages.getInstance().getErrorString("HttpUtil.ERROR_0001_URL_ERROR", e.getMessage()),
          e); //$NON-NLS-1$ //$NON-NLS-2$
      return null;
    }
  }