Class WarcReader

java.lang.Object
org.microproxy.warc.WarcReader
All Implemented Interfaces:
Closeable, AutoCloseable

public final class WarcReader extends Object implements Closeable
Reads WARC records (versions 1.0 and 1.1) one after another, as WarcRecorder writes them and as other archiving tools do: plain .warc files, or .warc.gz files with one gzip member per record (or one for the whole file). ServerReplay uses it to answer requests from recorded responses.

 try (WarcReader reader = WarcReader.open(Path.of("warcs/microproxy-....warc.gz"))) {
     for (WarcReader.Record r; (r = reader.next()) != null; ) {
         if (r.type().equals("response")) System.out.println(r.field("WARC-Target-URI"));
     }
 }
 

Each record's block is read into memory whole.

  • Constructor Details

    • WarcReader

      public WarcReader(InputStream in) throws IOException
      Reads records from in, which is decompressed if it starts with the gzip magic bytes.
      Parameters:
      in - the WARC data
      Throws:
      IOException - if the stream cannot be read
  • Method Details