本文整理汇总了Java中com.github.junrar.Archive.extractFile方法的典型用法代码示例。如果您正苦于以下问题:Java Archive.extractFile方法的具体用法?Java Archive.extractFile怎么用?Java Archive.extractFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.junrar.Archive
的用法示例。
在下文中一共展示了Archive.extractFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unzipRAREntry
import com.github.junrar.Archive; //导入方法依赖的package包/类
private void unzipRAREntry(Archive zipfile, FileHeader header, String outputDir)
throws IOException, RarException {
output = new File(outputDir + "/" + header.getFileNameString().trim());
FileOutputStream fileOutputStream = new FileOutputStream(output);
zipfile.extractFile(header, fileOutputStream);
}
示例2: extractFile
import com.github.junrar.Archive; //导入方法依赖的package包/类
protected boolean extractFile(Archive archive, FileHeader fileHeader, File destFile) throws IOException {
final OutputStream out = new FileOutputStream(destFile);
try {
archive.extractFile(fileHeader, out);
files.addHandled(fileHeader.getFileNameString());
return true;
}
catch (RarException e) {
throw new IOException(e);
}
finally {
out.close();
}
}
示例3: read
import com.github.junrar.Archive; //导入方法依赖的package包/类
/**
* Read from compressed file
*
* @param srcPath
* path of compressed file
* @param fileCompressor
* FileCompressor object
* @throws Exception
*/
@Override
public void read(String srcPath, FileCompressor fileCompressor)
throws Exception {
long t1 = System.currentTimeMillis();
byte[] data = FileUtil.convertFileToByte(srcPath);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Archive arch = new Archive(new File(srcPath));
try {
if (arch.isEncrypted()) {
FileCompressor.LOGGER.error(fileCompressor.hashCode()
+ " Archive is encrypted. Cannot read <" + srcPath
+ ">");
return;
}
FileHeader entry = null;
while (true) {
entry = arch.nextFileHeader();
if (entry == null)
break;
if (entry.isDirectory()) {
continue;
}
String name = entry.isUnicode() ? entry.getFileNameW() : entry
.getFileNameString();
if (entry.isEncrypted()) {
FileCompressor.LOGGER.error(fileCompressor.hashCode()
+ " File is encrypted. Cannot read <" + name + ">");
continue;
}
long t2 = System.currentTimeMillis();
baos = new ByteArrayOutputStream();
arch.extractFile(entry, baos);
BinaryFile binaryFile = new BinaryFile(name, baos.toByteArray());
fileCompressor.addBinaryFile(binaryFile);
LogUtil.createAddFileLog(fileCompressor, binaryFile, t2,
System.currentTimeMillis());
}
} catch (Exception e) {
FileCompressor.LOGGER.error("Error on get compressor file", e);
} finally {
arch.close();
baos.close();
}
LogUtil.createReadLog(fileCompressor, srcPath, data.length, t1,
System.currentTimeMillis());
}