if(archive.exists() && archive.canRead()) {
if(archive.getName().endsWith("7z")) {
log.info("auto-detected archive format: 7Z");
final SevenZFile sevenZFile = new SevenZFile(archive);
try {
SevenZArchiveEntry entry;
while( (entry = sevenZFile.getNextEntry()) != null) {
if(! entry.isDirectory()) {
log.info("loading entry {} ...", entry.getName());
// detect the file format
RDFFormat detectedFormat = Rio.getParserFormatForFileName(entry.getName());
if(format == null) {
if(detectedFormat != null) {
log.info("auto-detected entry format: {}", detectedFormat.getName());
format = detectedFormat;
} else {
throw new RDFParseException("could not detect input format of entry "+ entry.getName());
}
} else {
if(detectedFormat != null && !format.equals(detectedFormat)) {
log.warn("user-specified entry format ({}) overrides auto-detected format ({})", format.getName(), detectedFormat.getName());
} else {
log.info("user-specified entry format: {}", format.getName());
}
}
load(new InputStream() {
@Override
public int read() throws IOException {
return sevenZFile.read();
}
@Override
public int read(byte[] b) throws IOException {
return sevenZFile.read(b);
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
return sevenZFile.read(b, off, len);
}
},handler,format);
}
}
} finally {
sevenZFile.close();
}
} else {
InputStream in;