Class WarcWriter
java.lang.Object
org.netpreserve.jwarc.WarcWriter
-
Constructor Summary
ConstructorsConstructorDescriptionWarcWriter(OutputStream stream) WarcWriter(WritableByteChannel channel) WarcWriter(WritableByteChannel channel, WarcCompression compression) WarcWriter(Path path) Opens a WARC file for writing. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the channel.Downloads a remote resource recording the request and response as WARC records.fetch(URI uri, FetchOptions options) Downloads a remote resource recording the request and response as WARC records.fetch(URI uri, HttpRequest httpRequest, OutputStream copyTo) Downloads a remote resource recording the request and response as WARC records.fetch(URI uri, HttpRequest httpRequest, FetchOptions options) Downloads a remote resource recording the request and response as WARC records.longposition()Returns the byte position the next record will be written to.voidwrite(WarcRecord record)
-
Constructor Details
-
WarcWriter
- Throws:
IOException
-
WarcWriter
- Throws:
IOException
-
WarcWriter
- Throws:
IOException
-
WarcWriter
Opens a WARC file for writing. Compression is determined by the file extension.- Parameters:
path- the path to the file- Throws:
IOException- if an I/O error occurs
-
-
Method Details
-
write
- Throws:
IOException
-
fetch
Downloads a remote resource recording the request and response as WARC records.- Throws:
IOException
-
fetch
Downloads a remote resource recording the request and response as WARC records.- Parameters:
uri- URL to downloadoptions- fetch options to use- Throws:
IOException- if an IO error occurred
-
fetch
Downloads a remote resource recording the request and response as WARC records.- Parameters:
uri- URL to downloadhttpRequest- request to sendcopyTo- if not null will receive a copy of the (raw) http response bytes- Throws:
IOException- if an IO error occurred
-
fetch
Downloads a remote resource recording the request and response as WARC records.- Parameters:
uri- URL to downloadhttpRequest- request to sendoptions- 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
Closes the channel. If there are any active fetches they will be truncated and current progress written.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-