本文整理了Java中net.lingala.zip4j.model.ZipModel.getEndCentralDirRecord()
方法的一些代码示例,展示了ZipModel.getEndCentralDirRecord()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipModel.getEndCentralDirRecord()
方法的具体详情如下:
包路径:net.lingala.zip4j.model.ZipModel
类名称:ZipModel
方法名:getEndCentralDirRecord
暂无
代码示例来源:origin: net.lingala.zip4j/zip4j
public RandomAccessFile startNextSplitFile() throws IOException, FileNotFoundException {
String currZipFile = zipModel.getZipFile();
String partFile = null;
if (currSplitFileCounter == zipModel.getEndCentralDirRecord().getNoOfThisDisk()) {
partFile = zipModel.getZipFile();
} else {
if (currSplitFileCounter >= 9) {
partFile = currZipFile.substring(0, currZipFile.lastIndexOf(".")) + ".z" + (currSplitFileCounter + 1);
} else {
partFile = currZipFile.substring(0, currZipFile.lastIndexOf(".")) + ".z0" + (currSplitFileCounter + 1);
}
}
currSplitFileCounter++;
try {
if(!Zip4jUtil.checkFileExists(partFile)) {
throw new IOException("zip split file does not exist: " + partFile);
}
} catch (ZipException e) {
throw new IOException(e.getMessage());
}
return new RandomAccessFile(partFile, InternalZipConstants.READ_MODE);
}
代码示例来源:origin: net.lingala.zip4j/zip4j
private long calculateTotalWorkForMergeOp(ZipModel zipModel) throws ZipException {
long totSize = 0;
if (zipModel.isSplitArchive()) {
int totNoOfSplitFiles = zipModel.getEndCentralDirRecord().getNoOfThisDisk();
String partFile = null;
String curZipFile = zipModel.getZipFile();
int partNumber = 0;
for (int i = 0; i <= totNoOfSplitFiles; i++) {
if (partNumber == zipModel.getEndCentralDirRecord().getNoOfThisDisk()) {
partFile = zipModel.getZipFile();
} else {
if (partNumber >= 9) {
partFile = curZipFile.substring(0, curZipFile.lastIndexOf(".")) + ".z" + (partNumber+ 1);
} else{
partFile = curZipFile.substring(0, curZipFile.lastIndexOf(".")) + ".z0" + (partNumber+ 1);
}
}
totSize += Zip4jUtil.getFileLengh(new File(partFile));
}
}
return totSize;
}
}
代码示例来源:origin: com.github.axet/zip4j
public void finish() throws IOException, ZipException {
zipModel.getEndCentralDirRecord().setOffsetOfStartOfCentralDir(totalBytesWritten);
HeaderWriter headerWriter = new HeaderWriter();
headerWriter.finalizeZipFile(zipModel, outputStream);
}
代码示例来源:origin: net.lingala.zip4j/zip4j
public void finish() throws IOException, ZipException {
zipModel.getEndCentralDirRecord().setOffsetOfStartOfCentralDir(totalBytesWritten);
HeaderWriter headerWriter = new HeaderWriter();
headerWriter.finalizeZipFile(zipModel, outputStream);
}
代码示例来源:origin: net.lingala.zip4j/zip4j
private void updateSplitEndCentralDirectory(ZipModel zipModel) throws ZipException {
try {
if (zipModel == null) {
throw new ZipException("zip model is null - cannot update end of central directory for split zip model");
}
if (zipModel.getCentralDirectory()== null) {
throw new ZipException("corrupt zip model - getCentralDirectory, cannot update split zip model");
}
zipModel.getEndCentralDirRecord().setNoOfThisDisk(0);
zipModel.getEndCentralDirRecord().setNoOfThisDiskStartOfCentralDir(0);
zipModel.getEndCentralDirRecord().setTotNoOfEntriesInCentralDir(
zipModel.getCentralDirectory().getFileHeaders().size());
zipModel.getEndCentralDirRecord().setTotNoOfEntriesInCentralDirOnThisDisk(
zipModel.getCentralDirectory().getFileHeaders().size());
} catch (ZipException e) {
throw e;
} catch (Exception e) {
throw new ZipException(e);
}
}
代码示例来源:origin: com.github.axet/zip4j
private void updateSplitEndCentralDirectory(ZipModel zipModel) throws ZipException {
try {
if (zipModel == null) {
throw new ZipException("zip model is null - cannot update end of central directory for split zip model");
}
if (zipModel.getCentralDirectory()== null) {
throw new ZipException("corrupt zip model - getCentralDirectory, cannot update split zip model");
}
zipModel.getEndCentralDirRecord().setNoOfThisDisk(0);
zipModel.getEndCentralDirRecord().setNoOfThisDiskStartOfCentralDir(0);
zipModel.getEndCentralDirRecord().setTotNoOfEntriesInCentralDir(
zipModel.getCentralDirectory().getFileHeaders().size());
zipModel.getEndCentralDirRecord().setTotNoOfEntriesInCentralDirOnThisDisk(
zipModel.getCentralDirectory().getFileHeaders().size());
} catch (ZipException e) {
throw e;
} catch (Exception e) {
throw new ZipException(e);
}
}
代码示例来源:origin: net.lingala.zip4j/zip4j
if (this.zipModel.getEndCentralDirRecord() == null) {
throw new ZipException("end of central directory record is null, cannot read comment");
if (this.zipModel.getEndCentralDirRecord().getCommentBytes() == null ||
this.zipModel.getEndCentralDirRecord().getCommentBytes().length <= 0) {
return null;
return new String(this.zipModel.getEndCentralDirRecord().getCommentBytes(), encoding);
} catch (UnsupportedEncodingException e) {
throw new ZipException(e);
代码示例来源:origin: com.github.axet/zip4j
private long calculateTotalWorkForMergeOp(ZipModel zipModel) throws ZipException {
long totSize = 0;
if (zipModel.isSplitArchive()) {
int totNoOfSplitFiles = zipModel.getEndCentralDirRecord().getNoOfThisDisk();
NativeStorage partFile = null;
NativeStorage curZipFile = zipModel.getZipFile();
String curZipFileName = curZipFile.getName();
int partNumber = 0;
for (int i = 0; i <= totNoOfSplitFiles; i++) {
if (partNumber == zipModel.getEndCentralDirRecord().getNoOfThisDisk()) {
partFile = zipModel.getZipFile();
} else {
if (partNumber >= 9) {
partFile = curZipFile.getParent().open(curZipFileName.substring(0, curZipFileName.lastIndexOf(".")) + ".z" + (partNumber+ 1));
} else{
partFile = curZipFile.getParent().open(curZipFileName.substring(0, curZipFileName.lastIndexOf(".")) + ".z0" + (partNumber+ 1));
}
}
totSize += Zip4jUtil.getFileLengh(partFile);
}
}
return totSize;
}
}
代码示例来源:origin: net.lingala.zip4j/zip4j
String curZipFile = zipModel.getZipFile();
String partFile = null;
if (diskNumberStartOfFile == zipModel.getEndCentralDirRecord().getNoOfThisDisk()) {
partFile = zipModel.getZipFile();
} else {
代码示例来源:origin: com.github.axet/zip4j
public NativeFile startNextSplitFile() throws IOException, FileNotFoundException {
NativeStorage currZipFile = zipModel.getZipFile();
String currZipFileName = currZipFile.getName();
NativeStorage partFile = null;
if (currSplitFileCounter == zipModel.getEndCentralDirRecord().getNoOfThisDisk()) {
partFile = zipModel.getZipFile();
} else {
if (currSplitFileCounter >= 9) {
partFile = currZipFile.getParent().open(currZipFileName.substring(0, currZipFileName.lastIndexOf(".")) + ".z" + (currSplitFileCounter + 1));
} else {
partFile = currZipFile.getParent().open(currZipFileName.substring(0, currZipFileName.lastIndexOf(".")) + ".z0" + (currSplitFileCounter + 1));
}
}
currSplitFileCounter++;
try {
if(!Zip4jUtil.checkFileExists(partFile)) {
throw new IOException("zip split file does not exist: " + partFile);
}
} catch (ZipException e) {
throw new IOException(e.getMessage());
}
return partFile.read();
}
代码示例来源:origin: net.lingala.zip4j/zip4j
String curZipFile = zipModel.getZipFile();
String partFile = null;
if (partNumber == zipModel.getEndCentralDirRecord().getNoOfThisDisk()) {
partFile = zipModel.getZipFile();
} else {
代码示例来源:origin: net.lingala.zip4j/zip4j
private void updateSplitZip64EndCentralDirRec(ZipModel zipModel, ArrayList fileSizeList) throws ZipException {
if (zipModel == null) {
throw new ZipException("zip model is null, cannot update split Zip64 end of central directory record");
}
if (zipModel.getZip64EndCentralDirRecord() == null) {
return;
}
zipModel.getZip64EndCentralDirRecord().setNoOfThisDisk(0);
zipModel.getZip64EndCentralDirRecord().setNoOfThisDiskStartOfCentralDir(0);
zipModel.getZip64EndCentralDirRecord().setTotNoOfEntriesInCentralDirOnThisDisk(
zipModel.getEndCentralDirRecord().getTotNoOfEntriesInCentralDir());
long offsetStartCenDirWRTStartDiskNo = 0;
for (int i = 0; i < fileSizeList.size(); i++) {
offsetStartCenDirWRTStartDiskNo += ((Long)fileSizeList.get(i)).longValue();
}
zipModel.getZip64EndCentralDirRecord().setOffsetStartCenDirWRTStartDiskNo(
((Zip64EndCentralDirRecord)zipModel.getZip64EndCentralDirRecord()).getOffsetStartCenDirWRTStartDiskNo() +
offsetStartCenDirWRTStartDiskNo);
}
代码示例来源:origin: com.github.axet/zip4j
private void updateSplitZip64EndCentralDirRec(ZipModel zipModel, ArrayList fileSizeList) throws ZipException {
if (zipModel == null) {
throw new ZipException("zip model is null, cannot update split Zip64 end of central directory record");
}
if (zipModel.getZip64EndCentralDirRecord() == null) {
return;
}
zipModel.getZip64EndCentralDirRecord().setNoOfThisDisk(0);
zipModel.getZip64EndCentralDirRecord().setNoOfThisDiskStartOfCentralDir(0);
zipModel.getZip64EndCentralDirRecord().setTotNoOfEntriesInCentralDirOnThisDisk(
zipModel.getEndCentralDirRecord().getTotNoOfEntriesInCentralDir());
long offsetStartCenDirWRTStartDiskNo = 0;
for (int i = 0; i < fileSizeList.size(); i++) {
offsetStartCenDirWRTStartDiskNo += ((Long)fileSizeList.get(i)).longValue();
}
zipModel.getZip64EndCentralDirRecord().setOffsetStartCenDirWRTStartDiskNo(
((Zip64EndCentralDirRecord)zipModel.getZip64EndCentralDirRecord()).getOffsetStartCenDirWRTStartDiskNo() +
offsetStartCenDirWRTStartDiskNo);
}
代码示例来源:origin: com.github.axet/zip4j
private void initZipModel(ZipModel zipModel) {
if (zipModel == null) {
this.zipModel = new ZipModel();
} else {
this.zipModel = zipModel;
}
if (this.zipModel.getEndCentralDirRecord() == null)
this.zipModel.setEndCentralDirRecord(new EndCentralDirRecord());
if (this.zipModel.getCentralDirectory() == null)
this.zipModel.setCentralDirectory(new CentralDirectory());
if (this.zipModel.getCentralDirectory().getFileHeaders() == null)
this.zipModel.getCentralDirectory().setFileHeaders(new ArrayList());
if (this.zipModel.getLocalFileHeaderList() == null)
this.zipModel.setLocalFileHeaderList(new ArrayList());
if (this.outputStream instanceof SplitOutputStream) {
if (((SplitOutputStream)outputStream).isSplitZipFile()) {
this.zipModel.setSplitArchive(true);
this.zipModel.setSplitLength(((SplitOutputStream)outputStream).getSplitLength());
}
}
this.zipModel.getEndCentralDirRecord().setSignature(InternalZipConstants.ENDSIG);
}
代码示例来源:origin: net.lingala.zip4j/zip4j
private void initZipModel(ZipModel zipModel) {
if (zipModel == null) {
this.zipModel = new ZipModel();
} else {
this.zipModel = zipModel;
}
if (this.zipModel.getEndCentralDirRecord() == null)
this.zipModel.setEndCentralDirRecord(new EndCentralDirRecord());
if (this.zipModel.getCentralDirectory() == null)
this.zipModel.setCentralDirectory(new CentralDirectory());
if (this.zipModel.getCentralDirectory().getFileHeaders() == null)
this.zipModel.getCentralDirectory().setFileHeaders(new ArrayList());
if (this.zipModel.getLocalFileHeaderList() == null)
this.zipModel.setLocalFileHeaderList(new ArrayList());
if (this.outputStream instanceof SplitOutputStream) {
if (((SplitOutputStream)outputStream).isSplitZipFile()) {
this.zipModel.setSplitArchive(true);
this.zipModel.setSplitLength(((SplitOutputStream)outputStream).getSplitLength());
}
}
this.zipModel.getEndCentralDirRecord().setSignature(InternalZipConstants.ENDSIG);
}
代码示例来源:origin: net.lingala.zip4j/zip4j
int currSplitFileCounter = 0;
if (outputStream instanceof SplitOutputStream) {
zipModel.getEndCentralDirRecord().setOffsetOfStartOfCentralDir(
((SplitOutputStream)outputStream).getFilePointer());
currSplitFileCounter = ((SplitOutputStream)outputStream).getCurrSplitFileCounter();
zipModel.getZip64EndCentralDirLocator().setTotNumberOfDiscs(currSplitFileCounter + 1);
zipModel.getEndCentralDirRecord().setNoOfThisDisk(currSplitFileCounter);
zipModel.getEndCentralDirRecord().setNoOfThisDiskStartOfCentralDir(currSplitFileCounter);
} catch (IOException e) {
throw new ZipException(e);
代码示例来源:origin: com.github.axet/zip4j
int currSplitFileCounter = 0;
if (outputStream instanceof SplitOutputStream) {
zipModel.getEndCentralDirRecord().setOffsetOfStartOfCentralDir(
((SplitOutputStream)outputStream).getFilePointer());
currSplitFileCounter = ((SplitOutputStream)outputStream).getCurrSplitFileCounter();
zipModel.getZip64EndCentralDirLocator().setTotNumberOfDiscs(currSplitFileCounter + 1);
zipModel.getEndCentralDirRecord().setNoOfThisDisk(currSplitFileCounter);
zipModel.getEndCentralDirRecord().setNoOfThisDiskStartOfCentralDir(currSplitFileCounter);
} catch (IOException e) {
throw new ZipException(e);
代码示例来源:origin: net.lingala.zip4j/zip4j
/**
* Sets comment for the Zip file
* @param comment
* @throws ZipException
*/
public void setComment(String comment) throws ZipException {
if (comment == null) {
throw new ZipException("input comment is null, cannot update zip file");
}
if (!Zip4jUtil.checkFileExists(file)) {
throw new ZipException("zip file does not exist, cannot set comment for zip file");
}
readZipInfo();
if (this.zipModel == null) {
throw new ZipException("zipModel is null, cannot update zip file");
}
if (zipModel.getEndCentralDirRecord() == null) {
throw new ZipException("end of central directory is null, cannot set comment");
}
ArchiveMaintainer archiveMaintainer = new ArchiveMaintainer();
archiveMaintainer.setComment(zipModel, comment);
}
代码示例来源:origin: com.github.axet/zip4j
/**
* Sets comment for the Zip file
* @param comment
* @throws ZipException
*/
public void setComment(String comment) throws ZipException {
if (comment == null) {
throw new ZipException("input comment is null, cannot update zip file");
}
if (!Zip4jUtil.checkFileExists(file)) {
throw new ZipException("zip file does not exist, cannot set comment for zip file");
}
readZipInfo();
if (this.zipModel == null) {
throw new ZipException("zipModel is null, cannot update zip file");
}
if (zipModel.getEndCentralDirRecord() == null) {
throw new ZipException("end of central directory is null, cannot set comment");
}
ArchiveMaintainer archiveMaintainer = new ArchiveMaintainer();
archiveMaintainer.setComment(zipModel, comment);
}
代码示例来源:origin: net.lingala.zip4j/zip4j
long offsetCentralDir = zipModel.getEndCentralDirRecord().getOffsetOfStartOfCentralDir();
内容来源于网络,如有侵权,请联系作者删除!