java怎样生成epub文件 |
您所在的位置:网站首页 › epub如何使用 › java怎样生成epub文件 |
我必须以编程方式编辑epubs的html文件,所以我做的是解压缩.epub并创建一个解析器来对html文件进行必要的编辑 . 但是,当我使用我的代码将它们转换回.epub时,EpubChecker显示: Error: Required META-INF/container.xml resource is missing 当我解压缩我编辑的.epub时,container.xml存在且不会丢失 . 我知道mimetype和META-INF必须首先压缩 . 这是我将代码转换回epub的代码: FileOutputStream fos = new FileOutputStream(zipFile); ZipOutputStream zos = new ZipOutputStream(fos); System.out.println("Output to Zip : " + zipFile); writeMimeType(zos); ZipEntry container = new ZipEntry("META-INF\\container.xml"); zos.putNextEntry(container); FileInputStream inMime2 = new FileInputStream(SOURCE_FOLDER + File.separator + "META-INF\\container.xml"); int len2; while((len2 = inMime2.read(buffer)) > 0){ zos.write(buffer, 0, len2); } inMime2.close(); |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |