本文整理汇总了Java中com.github.junrar.rarfile.FileHeader.getFileNameString方法的典型用法代码示例。如果您正苦于以下问题:Java FileHeader.getFileNameString方法的具体用法?Java FileHeader.getFileNameString怎么用?Java FileHeader.getFileNameString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.junrar.rarfile.FileHeader
的用法示例。
在下文中一共展示了FileHeader.getFileNameString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFile
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
/**
* Creates a file in a specified destination directory
* @param fh the file to be created
* @param destination the destination to which the newly created file will be moved to
* @return
*/
private static File createFile(FileHeader fh, File destination) {
File f = null;
String name = null;
if (fh.isFileHeader() && fh.isUnicode()) {
name = fh.getFileNameW();
} else {
name = fh.getFileNameString();
}
f = new File(destination, name);
if (!f.exists()) {
try {
f = makeFile(destination, name);
} catch (IOException e) {
logger.error("error creating the new file: " + f.getName(), e);
}
}
return f;
}
示例2: acceptContainedFile
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
@Override
protected boolean acceptContainedFile(FileHeader file) throws IOException {
// Check our parent class will accept the file
if (!super.acceptContainedFile(file)) {
return false;
}
final String path = file.getFileNameString();
// Check the Media file handler will accept the file
if (!MediaFileHandler.acceptFileExtension(path)) {
LOG.trace("Rejecting unacceptable file extension: {}", file);
return false;
}
final long size = file.getFullUnpackSize();
if (!MediaFileHandler.acceptFileSize(size)) {
LOG.trace("Rejecting too small file: {} ({} bytes)", file, size);
return false;
}
return true;
}
示例3: createFile
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
private static File createFile(FileHeader fh, File destination) throws IOException {
File f = null;
String name = null;
if (fh.isFileHeader() && fh.isUnicode()) {
name = fh.getFileNameW();
} else {
name = fh.getFileNameString();
}
f = new File(destination, name);
if (!f.exists()) {
f = makeFile(destination, name);
}
return f;
}
示例4: createDirectory
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
private static void createDirectory(FileHeader fh, File destination) {
File f = null;
if (fh.isDirectory() && fh.isUnicode()) {
f = new File(destination, fh.getFileNameW());
if (!f.exists()) {
makeDirectory(destination, fh.getFileNameW());
}
} else if (fh.isDirectory() && !fh.isUnicode()) {
f = new File(destination, fh.getFileNameString());
if (!f.exists()) {
makeDirectory(destination, fh.getFileNameString());
}
}
}
示例5: headerRequired
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
private FileHeader headerRequired(FileHeader rowItem) {
for (FileHeader fileHeader : zipViewer.archive.getFileHeaders()) {
String req = fileHeader.getFileNameString();
if (rowItem.getFileNameString().equals(req))
return fileHeader;
}
return null;
}
示例6: doInBackground
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
@Override
protected ArrayList<CompressedObjectParcelable> doInBackground(Void... params) {
ArrayList<CompressedObjectParcelable> elements = new ArrayList<>();
try {
if (createBackItem) {
elements.add(0, new CompressedObjectParcelable());
}
Archive zipfile = new Archive(new File(fileLocation));
String relativeDirDiffSeparator = relativeDirectory.replace("/", "\\");
for (FileHeader header : zipfile.getFileHeaders()) {
String name = header.getFileNameString();//This uses \ as separator, not /
boolean isInBaseDir = (relativeDirDiffSeparator == null || relativeDirDiffSeparator.equals("")) && !name.contains("\\");
boolean isInRelativeDir = relativeDirDiffSeparator != null && name.contains("\\")
&& name.substring(0, name.lastIndexOf("\\")).equals(relativeDirDiffSeparator);
if (isInBaseDir || isInRelativeDir) {
elements.add(new CompressedObjectParcelable(RarHelper.convertName(header), 0, header.getDataSize(), header.isDirectory()));
}
}
Collections.sort(elements, new CompressedObjectParcelable.Sorter());
} catch (RarException | IOException e) {
e.printStackTrace();
}
return elements;
}
示例7: unzipRAREntry
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
private void unzipRAREntry(@NonNull final Context context, Archive zipFile, FileHeader entry, String outputDir)
throws RarException, IOException {
String name = entry.getFileNameString();
name = name.replaceAll("\\\\", "/");
if (entry.isDirectory()) {
FileUtil.mkdir(new File(outputDir, name), context);
return;
}
File outputFile = new File(outputDir, name);
if (!outputFile.getParentFile().exists()) {
FileUtil.mkdir(outputFile.getParentFile(), context);
}
// Log.i("Amaze", "Extracting: " + entry);
BufferedInputStream inputStream = new BufferedInputStream(
zipFile.getInputStream(entry));
BufferedOutputStream outputStream = new BufferedOutputStream(
FileUtil.getOutputStream(outputFile, context, entry.getFullUnpackSize()));
try {
int len;
byte buf[] = new byte[GenericCopyUtil.DEFAULT_BUFFER_SIZE];
while ((len = inputStream.read(buf)) > 0) {
outputStream.write(buf, 0, len);
ServiceWatcherUtil.POSITION += len;
}
} finally {
outputStream.close();
inputStream.close();
}
}
示例8: createDirectory
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
/**
* Creates a directory within another specified directory
* @param fh
* @param destination the directory where the new directory will be placed
*/
private static void createDirectory(FileHeader fh, File destination) {
File f = null;
if (fh.isDirectory() && fh.isUnicode()) {
f = new File(destination, fh.getFileNameW());
if (!f.exists()) {
makeDirectory(destination, fh.getFileNameW());
}
} else if (fh.isDirectory() && !fh.isUnicode()) {
f = new File(destination, fh.getFileNameString());
if (!f.exists()) {
makeDirectory(destination, fh.getFileNameString());
}
}
}
示例9: unzipRAREntry
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
private void unzipRAREntry(int id,String a, Archive zipfile, FileHeader entry, String outputDir)
throws IOException, RarException {
String name=entry.getFileNameString();
name=name.replaceAll("\\\\","/");
if (entry.isDirectory()) {
createDir(new File(outputDir, name));
return;
}
File outputFile = new File(outputDir, name);
if (!outputFile.getParentFile().exists()) {
createDir(outputFile.getParentFile());
}
// Log.i("Amaze", "Extracting: " + entry);
BufferedInputStream inputStream = new BufferedInputStream(
zipfile.getInputStream(entry));
BufferedOutputStream outputStream = new BufferedOutputStream(
new FileOutputStream(outputFile));
try {
int len;
byte buf[] = new byte[20480];
while ((len = inputStream.read(buf)) > 0) {
//System.out.println(id + " " + hash.get(id));
if (hash.get(id)) {
outputStream.write(buf, 0, len);
copiedbytes=copiedbytes+len;
int p=(int) ((copiedbytes / (float) totalbytes) * 100);
if(p!=lastpercent || lastpercent==0){
publishResults(a,p,id,totalbytes,copiedbytes,false);
publishResults(true);
}
lastpercent=p;
} else {
publishResults(a,100,id,totalbytes,copiedbytes,true);
publishResults(false);
stopSelf(id);
}
}
}finally {
outputStream.close();
inputStream.close();
}
}
示例10: read
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的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());
}
示例11: getName
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
private String getName(FileHeader header) {
return header.isUnicode() ? header.getFileNameW() : header.getFileNameString();
}