Class WarcWriter

java.lang.Object
org.netpreserve.jwarc.WarcWriter
All Implemented Interfaces:
Closeable, AutoCloseable

public class WarcWriter extends Object implements Closeable
Writes records to a WARC file.
  • Constructor Details

  • Method Details

    • write

      public void write(WarcRecord record) throws IOException
      Throws:
      IOException
    • fetch

      public FetchResult fetch(URI uri) throws IOException
      Downloads a remote resource recording the request and response as WARC records.
      Throws:
      IOException
    • fetch

      public FetchResult fetch(URI uri, FetchOptions options) throws IOException
      Downloads a remote resource recording the request and response as WARC records.

      Parameters:
      uri - URL to download
      options - fetch options to use
      Throws:
      IOException - if an IO error occurred
    • fetch

      public FetchResult fetch(URI uri, HttpRequest httpRequest, OutputStream copyTo) throws IOException
      Downloads a remote resource recording the request and response as WARC records.

      Parameters:
      uri - URL to download
      httpRequest - request to send
      copyTo - if not null will receive a copy of the (raw) http response bytes
      Throws:
      IOException - if an IO error occurred
    • fetch

      public FetchResult fetch(URI uri, HttpRequest httpRequest, FetchOptions options) throws IOException
      Downloads a remote resource recording the request and response as WARC records.

      Parameters:
      uri - URL to download
      httpRequest - request to send
      options - fetch options to use
      Throws:
      IOException - if an IO error occurred
    • position

      public long position()
      Returns the byte position the next record will be written to.

      If the underlying channel is not seekable the returned value will be relative to the position the channel was in when the WarcWriter was created.

    • close

      public void close() throws IOException
      Closes the channel. If there are any active fetches they will be truncated and current progress written.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException