Пример #1
0
  public static void main(String[] args) throws IOException {
    StreamUtils.readLines(
        filename,
        new LineHandler() {
          int lineNum = 0;
          long lastTime = 0;

          @Override
          public void handleLine(String line) {
            try {
              lineNum++;

              String[] parts = line.split("\\s");

              long ts = insdf.parse(parts[0]).getTime();
              logTime(lastTime, ts);

              if ("I".equals(parts[1])) {
                // input
                System.out.println("IN " + parts[2]);
                inputQueue.push(parts[2]);
                parseData(inputQueue, inputParser);
              } else if ("O".equals(parts[1])) {
                // output
                System.out.println("OUT " + parts[2]);
                outputQueue.push(parts[2]);
                parseData(outputQueue, outputParser);
              } else {
                // comment
                String comment = line.substring(line.indexOf(" ") + 1);
                System.out.println(comment);
              }

              lastTime = ts;
            } catch (Exception e) {
              throw new RuntimeException("Exception on line " + lineNum, e);
            }

            //                if (lineNum > 5000)
            //                    throw new RuntimeException("STOP");
          }

          @Override
          public void done() {
            // no op
          }
        });
  }
Пример #2
0
 public static void writeChart(HttpServletResponse response, byte[] chartData) throws IOException {
   response.setContentType(getContentType());
   StreamUtils.transfer(new ByteArrayInputStream(chartData), response.getOutputStream());
 }