示例#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;
  }