コード例 #1
1
ファイル: Rag.java プロジェクト: pabloloyola/soot
  public void runImpl() throws Exception {
    // create the URL corresponding to the date

    URL u = new URL(ADDRESS_ + dateFormatter1_.format(date));
    Messages.debug(3, "Rag::runImpl - reading data from URL=%1", u);
    // fetch the page into the buffer
    buffer_ = new char[BUF_SIZE_];
    Reader r = new InputStreamReader(u.openStream());
    int size = 1;
    charsread_ = 0;
    while (charsread_ < BUF_SIZE_ && size > 0) {
      size = r.read(buffer_, 0, BUF_SIZE_ - charsread_);
      if (size != -1) charsread_ += size;
      // Messages.debug(3, "Rag::runImpl - read %1 chars", String.valueOf(size));
      if (!r.ready()) break;
    }
    r.close();
    // Messages.debug(3, "Rag::runImpl - buffer=\"%1\"XXXXXXX", new String(buffer_, 0, charsread_));
    // create the results
    createResults_();
  }
コード例 #2
0
    public void run() {
      try {
        // An arbitrary buffer size.
        char[] chbuf = new char[4096];

        while (keepRunning) {
          int numchars = reader.read(chbuf);
          if (numchars == -1) {
            keepRunning = false;
          } else if (keepRunning) {
            writer.write(chbuf, 0, numchars);
            if (!reader.ready()) {
              writer.flush();
            }
          }
        }
      } catch (IOException ex) {
        println("Error when linking JVM output to terminal window input.");
      }
    }