コード例 #1
0
ファイル: SpecProps.java プロジェクト: jysunhy/disl-android
  /**
   * Loads the propertis from the file given the URL
   *
   * @param urlString URL of the file to be used for loading he properties
   * @param p Properties
   */
  private static void loadPropertyFile(Properties p, String urlString) {

    if (urlString == null) {
      spec.harness.Context.out.println("Null urlString");
      return;
    }

    try {
      URL url = new URL(urlString);
      boolean ok = true;

      int ind = urlString.indexOf("http:", 0);
      // spec.harness.Context.out.println( urlString + "=" + ind);
      if (ind == 0) {
        ok = spec.io.FileInputStream.IsURLOk(url);
      }

      if (ok) {
        InputStream str = url.openStream();
        if (str == null) {
          spec.harness.Context.out.println("InputStream in loadPropertyFile is null");
        } else {
          p.load(new BufferedInputStream(str));
        }
      } else {
        spec.harness.Context.out.println("Could not open URL " + urlString);
      }

    } catch (Exception e) {
      spec.harness.Context.out.println("Error loading property file " + urlString + " : " + e);
      //	e.printStackTrace( spec.harness.Context.out );
    }
  }