Skip to content

Update EpubWriter.java #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/main/java/coza/opencollab/epub/creator/util/EpubWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ private long calculateCrc(byte[] data) {
* @throws IOException
*/
private void addStringToZip(ZipOutputStream resultStream, String fileName, String content) throws IOException {
resultStream.putNextEntry(new ZipEntry(fileName));
ZipEntry entry = new ZipEntry(fileName);
entry.setMethod(ZipEntry.STORED);
entry.setSize(content.getBytes("UTF-8").length);
entry.setCrc(calculateCrc(content.getBytes("UTF-8")));
resultStream.putNextEntry(entry);
Writer out = new OutputStreamWriter(resultStream, "UTF-8");
out.write(content);
out.flush();
Expand All @@ -139,7 +143,11 @@ private void addStringToZip(ZipOutputStream resultStream, String fileName, Strin
*/
private void addContent(ZipOutputStream resultStream, List<Content> contents) throws IOException {
for (Content content : contents) {
resultStream.putNextEntry(new ZipEntry(contentFolder + "/" + content.getHref()));
ZipEntry entry = new ZipEntry(contentFolder + "/" + content.getHref());
entry.setMethod(ZipEntry.STORED);
entry.setSize(content.getContent().length);
entry.setCrc(calculateCrc(content.getContent()));
resultStream.putNextEntry(entry);
resultStream.write(content.getContent());
}
}
Expand Down