Exemplo n.º 1
0
  private int fill_text_buffer(String infile) {
    int act = 0;
    int num_bytes = 0;
    System.out.println("DEBUG:" + infile);
    try {

      spec.io.FileInputStream sif = new spec.io.FileInputStream(infile);
      num_bytes = (int) sif.getContentLength();

      // Only allocate size of input file rather than MAX - kmd
      // If compressed file is larger than input file this allocation
      // will fail and out of bound exception will occur
      // In real lie, compress will no do any compression as no
      // space is saved.-- kaivalya

      orig_text_buffer = new byte[num_bytes];
      comp_text_buffer = new byte[num_bytes];

      int bytes_read;
      while ((bytes_read = sif.read(orig_text_buffer, act, (num_bytes - act))) > 0) {
        act = act + bytes_read;
      }

      sif.close(); // release resources

      if (act != num_bytes) {
        spec.harness.Context.out.println("ERROR reading test input file");
      }
    } catch (IOException e) {
      spec.harness.Context.out.println("ERROR opening/accessing input file: " + infile);
    }
    ;

    return act;
  }
Exemplo n.º 2
0
  /**
   * 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 );
    }
  }