Class WaczWriter
java.lang.Object
org.netpreserve.jwarc.WaczWriter
- All Implemented Interfaces:
Closeable, AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a page entry to pages.jsonl.voidclose()Finishes writing the WACZ file and closes the underlying output stream.voidfinish()Finishes writing the WACZ file without closing the underlying output stream.voidSets a metadata property to be included in datapackage.json.voidsetAutoPages(boolean enabled) Enables or disables automatic detection of pages from WARC records.voidwriteResource(String path, Path source) Writes the content of the provided source file to a WACZ resource at the specified path.
-
Constructor Details
-
WaczWriter
- Throws:
IOException
-
WaczWriter
- Throws:
IOException
-
-
Method Details
-
writeResource
Writes the content of the provided source file to a WACZ resource at the specified path. The source file is read twice as the zip CRC needs to be calculated before writing the ZIP entry.- Parameters:
path- the path of the resource where the content will be writtensource- thePathof the file whose content is to be copied to the resource- Throws:
IOException- if an I/O error occurs while writing the resource or reading the source fileIllegalArgumentException- if a resource with the same path has already been writtenIllegalStateException- if the WACZ file has already been finished
-
addPage
Adds a page entry to pages.jsonl.- Parameters:
url- the URL of the pagets- the timestamp in RFC3339 formattitle- an optional title for the page- Throws:
IOException
-
finish
Finishes writing the WACZ file without closing the underlying output stream.- Throws:
IOException- if an I/O error occurs
-
close
Finishes writing the WACZ file and closes the underlying output stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error occurs
-
set
-
setAutoPages
public void setAutoPages(boolean enabled) Enables or disables automatic detection of pages from WARC records. If disabled, only pages added viaaddPage(String, Instant, String)will be included.
-