本文整理了Java中com.github.junrar.Archive
类的一些代码示例,展示了Archive
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Archive
类的具体详情如下:
包路径:com.github.junrar.Archive
类名称:Archive
[英]The Main Rar Class; represents a rar Archive
[中]主要Rar类;表示rar存档
代码示例来源:origin: apache/tika
try (TemporaryResources tmp = new TemporaryResources()) {
TikaInputStream tis = TikaInputStream.get(stream, tmp);
rar = new Archive(new FileVolumeManager(tis.getFile()));
if (rar.isEncrypted()) {
throw new EncryptedDocumentException();
FileHeader header = rar.nextFileHeader();
while (header != null && !Thread.currentThread().isInterrupted()) {
if (!header.isDirectory()) {
try (InputStream subFile = rar.getInputStream(header)) {
Metadata entrydata = PackageParser.handleEntryMetadata(
"".equals(header.getFileNameW()) ? header.getFileNameString() : header.getFileNameW(),
header = rar.nextFileHeader();
} finally {
if (rar != null)
rar.close();
代码示例来源:origin: SeanDragon/protools
try (Archive archive = new Archive(rarFile)) {
FileHeader fh = archive.nextFileHeader();
while (fh != null) {
String compressFileName = fh.getFileNameString().trim();
destFile.mkdirs();
fh = archive.nextFileHeader();
continue;
archive.extractFile(fh, fos);
fh = archive.nextFileHeader();
代码示例来源:origin: mucommander/mucommander
public Collection<FileHeader> getEntries() {
return archive.getFileHeaders();
}
代码示例来源:origin: edmund-wagner/junrar
Archive a = null;
try {
a = new Archive(new FileVolumeManager(f));
} catch (RarException e) {
a.getMainHeader().print();
FileHeader fh = a.nextFileHeader();
while (fh != null) {
try {
System.out.println(out.getAbsolutePath());
FileOutputStream os = new FileOutputStream(out);
a.extractFile(fh, os);
os.close();
} catch (FileNotFoundException e) {
fh = a.nextFileHeader();
代码示例来源:origin: digital-preservation/droid
@Override
public void handle(IdentificationRequest request) throws IOException {
VolumeManager readerVolume = new RarReader(request.getWindowReader());
try {
try (Archive archive = new Archive(readerVolume)) {
if (archive.isEncrypted()) {
throw new RuntimeException("Encrypted archive");
}
RarWalker walker = new RarWalker(archive, request.getIdentifier());
walker.walk(archive.getFileHeaders());
}
} catch (RarException ex) {
throw new RuntimeException("Rar processing failed :", ex);
}
}
代码示例来源:origin: edmund-wagner/junrar
count -= retCode;
unpPackedSize -= retCode;
archive.bytesReadRead(retCode);
if (unpPackedSize == 0 && subHead.isSplitAfter()) {
Volume nextVolume = archive.getVolumeManager().nextArchive(
archive, archive.getVolume());
if (nextVolume == null) {
nextVolumeMissing = true;
throw new RarException(RarExceptionType.crcError);
UnrarCallback callback = archive.getUnrarCallback();
if ((callback != null)
&& !callback.isNextVolumeReady(nextVolume)) {
return -1;
archive.setVolume(nextVolume);
hd = archive.nextFileHeader();
if (hd == null) {
return -1;
代码示例来源:origin: com.github.junrar/junrar
this.archive = new Archive(new VFSVolumeManager(this.parentLayer));
for (final FileHeader header : this.archive.getFileHeaders()) {
final AbstractFileName name = (AbstractFileName) getFileSystemManager()
.resolveName(
代码示例来源:origin: stackoverflow.com
FileHeader fh = a.nextFileHeader();
while (fh != null) {
try {
a.extractFile(fh, os);
os.close();
e.printStackTrace();
fh = a.nextFileHeader();
代码示例来源:origin: com.github.junrar/junrar
private static Archive createArchiveOrThrowException(final Log logger, final InputStream rarAsStream) throws RarException, IOException {
try {
return new Archive(rarAsStream);
} catch (final RarException e) {
logger.error(e);
throw e;
} catch (final IOException e1) {
logger.error(e1);
throw e1;
}
}
代码示例来源:origin: com.github.junrar/junrar
@Override
protected InputStream doGetInputStream() throws Exception {
if (!getType().hasContent()) {
throw new FileSystemException("vfs.provider/read-not-file.error",
getName());
}
return archive.getInputStream(header);
}
代码示例来源:origin: com.github.junrar/junrar
private static List<File> extractArchiveTo(final Archive arch, final ExtractDestination destination) throws IOException, RarException {
if (arch.isEncrypted()) {
logger.warn("archive is encrypted cannot extract");
arch.close();
return new ArrayList<File>();
}
final List<File> extractedFiles = new ArrayList<File>();
try{
for(final FileHeader fh : arch ) {
try {
final File file = tryToExtract(logger, destination, arch, fh);
if (file != null) {
extractedFiles.add(file);
}
} catch (final IOException e) {
logger.error("error extracting the file", e);
throw e;
} catch (final RarException e) {
logger.error("error extraction the file", e);
throw e;
}
}
}finally {
arch.close();
}
return extractedFiles;
}
代码示例来源:origin: edmund-wagner/junrar
public void run() {
try {
extractFile(hd, out);
} catch (RarException e) {
} finally {
try {
out.close();
} catch (IOException e) {
}
}
}
}).start();
代码示例来源:origin: com.github.junrar/junrar
@Override
public FileHeader next() {
FileHeader next;
if(Archive.this.nextFileHeader != null) {
next = Archive.this.nextFileHeader;
}else {
next = nextFileHeader();
}
return next;
}
代码示例来源:origin: edmund-wagner/junrar
private void setFile(IReadOnlyAccess file, long length) throws IOException {
totalPackedSize = 0L;
totalPackedRead = 0L;
close();
rof = file;
try {
readHeaders(length);
} catch (Exception e) {
logger.log(Level.WARNING,
"exception in archive constructor maybe file is encrypted "
+ "or currupt", e);
// ignore exceptions to allow exraction of working files in
// corrupt archive
}
// Calculate size of packed data
for (BaseBlock block : headers) {
if (block.getHeaderType() == UnrarHeadertype.FileHeader) {
totalPackedSize += ((FileHeader) block).getFullPackSize();
}
}
if (unrarCallback != null) {
unrarCallback.volumeProgressChanged(totalPackedRead,
totalPackedSize);
}
}
代码示例来源:origin: com.github.junrar/junrar
@Override
protected void doCloseCommunicationLink() {
try {
this.archive.close();
} catch (final FileSystemException e) {
throw new RuntimeException(e);
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: uk.gov.nationalarchives/droid-core-interfaces
@Override
public void handle(IdentificationRequest request) throws IOException {
if (request.getClass().isAssignableFrom(FileSystemIdentificationRequest.class)) {
FileSystemIdentificationRequest req = (FileSystemIdentificationRequest) request;
FileVolumeManager fileVolumeManager = new FileVolumeManager(req.getFile());
try {
try (Archive archive = new Archive(fileVolumeManager)) {
if (archive.isEncrypted()) {
throw new RuntimeException("Encrypted archive");
}
RarWalker walker = new RarWalker(archive, req.getIdentifier());
walker.walk(archive.getFileHeaders());
}
} catch (RarException ex) {
throw new RuntimeException("Rar procesing failed :", ex);
}
} else {
log.info("Identification request for RAR archive ignored due to limited support.");
}
}
代码示例来源:origin: com.github.junrar/junrar
count -= retCode;
unpPackedSize -= retCode;
archive.bytesReadRead(retCode);
if (unpPackedSize == 0 && subHead.isSplitAfter()) {
Volume nextVolume = archive.getVolumeManager().nextArchive(archive, archive.getVolume());
if (nextVolume == null) {
nextVolumeMissing = true;
throw new RarException(RarExceptionType.crcError);
UnrarCallback callback = archive.getUnrarCallback();
if ((callback != null)
&& !callback.isNextVolumeReady(nextVolume)) {
return -1;
archive.setVolume(nextVolume);
hd = archive.nextFileHeader();
if (hd == null) {
return -1;
代码示例来源:origin: edmund-wagner/junrar
archive = new Archive(new VFSVolumeManager(parentLayer));
for (final FileHeader header : archive.getFileHeaders()) {
AbstractFileName name = (AbstractFileName) getFileSystemManager()
.resolveName(
代码示例来源:origin: com.github.junrar/junrar
public static List<File> extract(
final ExtractDestination destination,
final VolumeManager volumeManager
) throws RarException, IOException {
final Archive archive = new Archive(volumeManager);
return extractArchiveTo(archive, destination);
}
代码示例来源:origin: edmund-wagner/junrar
@Override
protected InputStream doGetInputStream() throws Exception {
if (!getType().hasContent()) {
throw new FileSystemException("vfs.provider/read-not-file.error",
getName());
}
return archive.getInputStream(header);
}
内容来源于网络,如有侵权,请联系作者删除!