use of org.apache.commons.compress.archivers.zip.ZipArchiveEntry in project AozoraEpub3 by hmdev.
the class Epub3Writer method startSection.
/** セクション開始.
* @throws IOException */
void startSection(int lineNum, int pageType, int imagePageType, String srcImageFilePath) throws IOException {
this.sectionIndex++;
String sectionId = decimalFormat.format(this.sectionIndex);
//package.opf用にファイル名
SectionInfo sectionInfo = new SectionInfo(sectionId);
//次の行が単一画像なら画像専用指定
switch(imagePageType) {
case PageBreakType.IMAGE_PAGE_W:
//幅100%指定
sectionInfo.setImagePage(true);
sectionInfo.setImageFitW(true);
break;
case PageBreakType.IMAGE_PAGE_H:
//高さ100%指定
sectionInfo.setImagePage(true);
sectionInfo.setImageFitH(true);
break;
case PageBreakType.IMAGE_PAGE_NOFIT:
sectionInfo.setImagePage(true);
break;
}
if (pageType == PageBreakType.PAGE_MIDDLE)
sectionInfo.setMiddle(true);
else if (pageType == PageBreakType.PAGE_BOTTOM)
sectionInfo.setBottom(true);
this.sectionInfos.add(sectionInfo);
//セクション開始は名称がnullなので改ページ処理で文字列が設定されなければ出力されない 階層レベルは1
//this.addChapter(null, null, 1);
this.zos.putArchiveEntry(new ZipArchiveEntry(OPS_PATH + XHTML_PATH + sectionId + ".xhtml"));
//ヘッダ出力
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(zos, "UTF-8"));
//出力開始するセクションに対応したSectionInfoを設定
this.velocityContext.put("sectionInfo", sectionInfo);
Velocity.mergeTemplate(this.templatePath + OPS_PATH + XHTML_PATH + XHTML_HEADER_VM, "UTF-8", velocityContext, bw);
bw.flush();
}
use of org.apache.commons.compress.archivers.zip.ZipArchiveEntry in project dex2jar by pxb1988.
the class BadZipEntryFlagTest method test1.
@Test
public void test1() throws IOException {
ZipArchiveInputStream zis = new ZipArchiveInputStream(BadZipEntryFlagTest.class.getResourceAsStream("/bad.zip"));
for (ZipArchiveEntry e = zis.getNextZipEntry(); e != null; e = zis.getNextZipEntry()) {
e.getGeneralPurposeBit().useEncryption(false);
if (!e.isDirectory()) {
zis.read();
System.out.println(e.getName());
}
}
}
use of org.apache.commons.compress.archivers.zip.ZipArchiveEntry in project atlas by alibaba.
the class ZipUtils method extractZipFileToFolder.
/**
* 解压zip文件中的某个文件到指定地方
*
* @param zipFile
* @param path
* @param destFolder
* @throws IOException
*/
public static File extractZipFileToFolder(File zipFile, String path, File destFolder) {
ZipFile zip;
File destFile = null;
try {
zip = new ZipFile(zipFile);
ZipArchiveEntry zipArchiveEntry = zip.getEntry(path);
if (null != zipArchiveEntry) {
String name = zipArchiveEntry.getName();
name = FilenameUtils.getName(name);
destFile = new File(destFolder, name);
destFolder.mkdirs();
destFile.createNewFile();
InputStream is = zip.getInputStream(zipArchiveEntry);
FileOutputStream fos = new FileOutputStream(destFile);
int length = 0;
byte[] b = new byte[1024];
while ((length = is.read(b, 0, 1024)) != -1) {
fos.write(b, 0, length);
}
is.close();
fos.close();
}
if (null != zip)
ZipFile.closeQuietly(zip);
} catch (IOException e) {
e.printStackTrace();
}
return destFile;
}
use of org.apache.commons.compress.archivers.zip.ZipArchiveEntry in project atlas by alibaba.
the class ZipUtils method isFolderExist.
/**
* 判断在指定的zip目录下,指定的文件夹是否存在
*
* @param zipFile
* @param pathName
* @return
*/
public static boolean isFolderExist(File zipFile, String pathName) {
ZipFile file = null;
try {
file = new ZipFile(zipFile);
Enumeration<ZipArchiveEntry> en = file.getEntries();
while (en.hasMoreElements()) {
ZipArchiveEntry entry = en.nextElement();
String name = entry.getName();
if (name.startsWith(pathName)) {
return true;
}
}
return false;
} catch (IOException e) {
} finally {
if (null != file) {
try {
file.close();
} catch (IOException e) {
}
}
}
return false;
}
use of org.apache.commons.compress.archivers.zip.ZipArchiveEntry in project atlas by alibaba.
the class ZipUtils method extractZipFileToFolder.
/**
* 压zip文件中的某个文件到指定地方
*
* @param zipFile
* @param path
* @param destFolder
* @throws java.io.IOException
*/
public static File extractZipFileToFolder(File zipFile, String path, File destFolder) {
ZipFile zip;
File destFile = null;
try {
zip = new ZipFile(zipFile);
ZipArchiveEntry zipArchiveEntry = zip.getEntry(path);
if (null != zipArchiveEntry) {
String name = zipArchiveEntry.getName();
name = FilenameUtils.getName(name);
destFile = new File(destFolder, name);
FileMkUtils.mkdirs(destFolder);
destFile.createNewFile();
InputStream is = zip.getInputStream(zipArchiveEntry);
FileOutputStream fos = new FileOutputStream(destFile);
int length = 0;
byte[] b = new byte[1024];
while ((length = is.read(b, 0, 1024)) != -1) {
fos.write(b, 0, length);
}
is.close();
fos.close();
}
if (null != zip)
ZipFile.closeQuietly(zip);
} catch (IOException e) {
}
return destFile;
}
Aggregations