当前位置: 首页>>代码示例>>Java>>正文


Java RarException类代码示例

本文整理汇总了Java中com.github.junrar.exception.RarException的典型用法代码示例。如果您正苦于以下问题:Java RarException类的具体用法?Java RarException怎么用?Java RarException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RarException类属于com.github.junrar.exception包,在下文中一共展示了RarException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RarredFile

import com.github.junrar.exception.RarException; //导入依赖的package包/类
public RarredFile(File f) {
	this.f = f;
	setLastModified(f.lastModified());

	try {
		rarFile = new Archive(f);
		List<FileHeader> headers = rarFile.getFileHeaders();

		for (FileHeader fh : headers) {
			// if (fh.getFullUnpackSize() < MAX_ARCHIVE_ENTRY_SIZE && fh.getFullPackSize() < MAX_ARCHIVE_ENTRY_SIZE)
			addChild(new RarredEntry(fh.getFileNameString(), f, fh.getFileNameString(), fh.getFullUnpackSize()));
		}

		rarFile.close();
	} catch (RarException | IOException e) {
		LOGGER.error(null, e);
	}
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:19,代码来源:RarredFile.java

示例2: parse

import com.github.junrar.exception.RarException; //导入依赖的package包/类
@Override
public void parse(File file) throws IOException {
    try {
        mArchive = new Archive(file);
    }
    catch (RarException e) {
        throw new IOException("unable to open archive");
    }

    FileHeader header = mArchive.nextFileHeader();
    while (header != null) {
        if (!header.isDirectory()) {
            String name = getName(header);
            if (Utils.isImage(name)) {
                mHeaders.add(header);
            }
        }

        header = mArchive.nextFileHeader();
    }

    Collections.sort(mHeaders, new NaturalOrderComparator() {
        @Override
        public String stringValue(Object o) {
            return getName((FileHeader) o);
        }
    });
}
 
开发者ID:nkanaev,项目名称:bubble,代码行数:29,代码来源:RarParser.java

示例3: main

import com.github.junrar.exception.RarException; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	Integer numberOfPages = 5;
	File path = new File("/Users/sparksmith/comicReader/");
	DeleteMe testing = new DeleteMe();

	//LibraryPopulatorService archiver = new LibraryPopulatorService();
	try {
		ComicBook test = LibraryPopulatorService.getComicBook(new File("/Users/sparksmith/Documents/Programming/GITHUB/TheComicBook/"
				+ "The Comic Book/testFiles/testComic2.cbz"));
		System.out.println("The file: " + test.getFileName() + "\n" + "With size: " + test.getFileSize() + "MB\n" + "With filetype: "
				+ test.getFileType() + "\n" + "With original archiving method: " + test.getOriginalArchiving() + "\n"
				+ "With number of pages: " + test.getNumberOfPages());
		ArrayList<BufferedImage> t2 = ImageExtractingService.getImages(test, path, 22, 33, Destination.RAM);
		System.out.println("Size: " + t2.size());
		testing.start(t2.get(3));
	} catch (fileNotFound | IOException | RarException e) {
		e.printStackTrace();
	}
}
 
开发者ID:sparksmith,项目名称:TheComicBook,代码行数:23,代码来源:Main.java

示例4: openRarAddMetadata

import com.github.junrar.exception.RarException; //导入依赖的package包/类
/**
 * Extract information regarding the CBR format
 * 
 * @param result
 *            path information about the file
 * @return more information regarding the file including the page numbers
 *         and size
 * @throws RarException
 * @throws IOException
 */
public ComicBook openRarAddMetadata(ComicBook result) throws RarException, IOException {
	int numberOfPages = 0;
	Archive rar = new Archive(new File(result.getFileSystempath()));
	FileHeader fileHeader = rar.nextFileHeader();
	while (fileHeader != null) {
		if (!fileHeader.isDirectory()) {
			//name = fileHeader.getFileNameString();
			if (fileHeader.getFileNameString().contains(".jpg")) {
				numberOfPages++;
			}
		}
		fileHeader = rar.nextFileHeader();
	}
	result.setNumberOfPages(numberOfPages);
	//TODO: Add more metadata from file if there is one
	rar.close();
	return result;
}
 
开发者ID:sparksmith,项目名称:TheComicBook,代码行数:29,代码来源:MetadataGatherer.java

示例5: doUnpack

import com.github.junrar.exception.RarException; //导入依赖的package包/类
public void doUnpack(int method, boolean solid) throws IOException,
    RarException {
if (unpIO.getSubHeader().getUnpMethod() == 0x30) {
    unstoreFile();
}
switch (method) {
case 15: // rar 1.5 compression
    unpack15(solid);
    break;
case 20: // rar 2.x compression
case 26: // files larger than 2GB
    unpack20(solid);
    break;
case 29: // rar 3.x compression
case 36: // alternative hash
    unpack29(solid);
    break;
}
   }
 
开发者ID:pabloalba,项目名称:komics,代码行数:20,代码来源:Unpack.java

示例6: readVMCode

import com.github.junrar.exception.RarException; //导入依赖的package包/类
private boolean readVMCode() throws IOException, RarException {
int FirstByte = getbits() >> 8;
addbits(8);
int Length = (FirstByte & 7) + 1;
if (Length == 7) {
    Length = (getbits() >> 8) + 7;
    addbits(8);
} else if (Length == 8) {
    Length = getbits();
    addbits(16);
}
List<Byte> vmCode = new ArrayList<Byte>();
for (int I = 0; I < Length; I++) {
    if (inAddr >= readTop - 1 && !unpReadBuf() && I < Length - 1) {
	return (false);
    }
    vmCode.add(Byte.valueOf((byte) (getbits() >> 8)));
    addbits(8);
}
return (addVMCode(FirstByte, vmCode, Length));
   }
 
开发者ID:pabloalba,项目名称:komics,代码行数:22,代码来源:Unpack.java

示例7: ariDecNormalize

import com.github.junrar.exception.RarException; //导入依赖的package包/类
public void ariDecNormalize() throws IOException, RarException
	{
//		while ((low ^ (low + range)) < TOP || range < BOT && ((range = -low & (BOT - 1)) != 0 ? true : true)) 
//		{
//			code = ((code << 8) | unpackRead.getChar()&0xff)&uintMask;
//			range = (range << 8)&uintMask;
//			low = (low << 8)&uintMask;
//		}

        // Rewrote for clarity
        boolean c2 = false;
		while ((low ^ (low + range)) < TOP || (c2 = range < BOT)) {
            if (c2) {
                range = (-low & (BOT - 1))&uintMask;
                c2 = false;
            }
			code = ((code << 8) | getChar())&uintMask;
			range = (range << 8)&uintMask;
			low = (low << 8)&uintMask;
		}
    }
 
开发者ID:pabloalba,项目名称:komics,代码行数:22,代码来源:RangeCoder.java

示例8: unzipRAREntry

import com.github.junrar.exception.RarException; //导入依赖的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);
}
 
开发者ID:DeFuture,项目名称:AmazeFileManager-master,代码行数:8,代码来源:ZipExtractTask.java

示例9: unzipTAREntry

import com.github.junrar.exception.RarException; //导入依赖的package包/类
private void unzipTAREntry(int id, TarArchiveInputStream zipfile, TarArchiveEntry entry, String outputDir,String string)
        throws IOException, RarException {
    String name=entry.getName();
    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);

    BufferedOutputStream outputStream = new BufferedOutputStream(
            new FileOutputStream(outputFile));
    try {
        int len;
        byte buf[] = new byte[20480];
        while ((len = zipfile.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(string,p,id,totalbytes,copiedbytes,false);
                    publishResults(true);}
                lastpercent=p;
            } else {
                publishResults(string, 100, id, totalbytes, copiedbytes, true);
                publishResults(false);
                stopSelf(id);
            }
        }
    }finally {
        outputStream.close();

    }
}
 
开发者ID:DeFuture,项目名称:AmazeFileManager-master,代码行数:40,代码来源:ExtractService.java

示例10: doInBackground

import com.github.junrar.exception.RarException; //导入依赖的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;
}
 
开发者ID:TeamAmaze,项目名称:AmazeFileManager,代码行数:30,代码来源:RarHelperTask.java

示例11: doInBackground

import com.github.junrar.exception.RarException; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... p) {
    final ExtractService extractService = this.extractService.get();
    if(extractService == null) return null;

    File f = new File(compressedPath);

    if (!compressedPath.equals(extractionPath)) {// custom extraction path not set, extract at default path
        extractionPath = f.getParent() + "/" + f.getName().substring(0, f.getName().lastIndexOf("."));
    } else if (extractionPath.endsWith("/")) {
        extractionPath = extractionPath + f.getName().substring(0, f.getName().lastIndexOf("."));
    }

    try {
        String path = f.getPath().toLowerCase();
        boolean isZip = path.endsWith(".zip") || path.endsWith(".jar") || path.endsWith(".apk");
        boolean isTar = path.endsWith(".tar") || path.endsWith(".tar.gz");
        boolean isRar = path.endsWith(".rar");

        if (entriesToExtract != null && entriesToExtract.length != 0) {
            if (isZip) extract(extractService, f, extractionPath, entriesToExtract);
            else if (isRar) extractRar(extractService, f, extractionPath, entriesToExtract);
        } else {
            if (isZip) extract(extractService, f, extractionPath);
            else if (isRar) extractRar(extractService, f, extractionPath);
            else if (isTar) extractTar(extractService, f, extractionPath);
        }
    } catch (IOException | RarException e) {
        Log.e("amaze", "Error while extracting file " + compressedPath, e);
        AppConfig.toast(extractService, extractService.getString(R.string.error));
    }
    return null;
}
 
开发者ID:TeamAmaze,项目名称:AmazeFileManager,代码行数:34,代码来源:ExtractService.java

示例12: unzipRAREntry

import com.github.junrar.exception.RarException; //导入依赖的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();
    }
}
 
开发者ID:TeamAmaze,项目名称:AmazeFileManager,代码行数:31,代码来源:ExtractService.java

示例13: fromFile

import com.github.junrar.exception.RarException; //导入依赖的package包/类
/**
 * Get the file, analyze it and return a filled in ComicBook
 * 
 * @param file
 *            -> the absolute path to the file
 * @return ComicBook -> filled with metadata that can be extracted and the
 *         images
 * @throws fileNotFound
 *             the file does not exists
 * @throws IOException
 *             the file can't be read
 * @throws RarException
 *             the file can't be un-archived
 */
private static ComicBook fromFile(final File file) throws fileNotFound, IOException, RarException {
	MetadataGatherer opener = new MetadataGatherer();
	ComicBook result = null;
	if (file.exists()) {
		result = new ComicBook(file);
		switch (result.getOriginalArchiving()) {
		// ZIP
		case ZIP:
			result = opener.openZipAddMetadata(result);
			break;
		// RAR -> is a bit special because it is not in the JDK
		case RAR:
			result = opener.openRarAddMetadata(result);
			break;
		case TAR:
			//TODO: Do the tar
			throw new fileNotFound("NOT IMPLEMENTED TAR TYPE");
			//break;
		case SEVENz:
			//TODO: Do the 7z
			throw new fileNotFound("NOT IMPLEMENTED 7z TYPE");
			//break;
		case ACE:
			//TODO: Do the ACE
			throw new fileNotFound("NOT IMPLEMENTED ACE TYPE");
			//break;
		default:
			//TODO: Need to change the error -> unsupported file type
			throw new fileNotFound("Cant unarchive the file");
		}
	} else {
		throw new fileNotFound("Comic book does not exist");
	}
	return result;
}
 
开发者ID:sparksmith,项目名称:TheComicBook,代码行数:50,代码来源:LibraryPopulatorService.java

示例14: extractFile

import com.github.junrar.exception.RarException; //导入依赖的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();
    }
}
 
开发者ID:reines,项目名称:mediamanager,代码行数:16,代码来源:RarFileHandler.java

示例15: unstoreFile

import com.github.junrar.exception.RarException; //导入依赖的package包/类
private void unstoreFile() throws IOException, RarException {
byte[] buffer = new byte[0x10000];
while (true) {
    int code = unpIO.unpRead(buffer, 0, (int) Math.min(buffer.length,
	    destUnpSize));
    if (code == 0 || code == -1)
	break;
    code = code < destUnpSize ? code : (int) destUnpSize;
    unpIO.unpWrite(buffer, 0, code);
    if (destUnpSize >= 0)
	destUnpSize -= code;
}

   }
 
开发者ID:pabloalba,项目名称:komics,代码行数:15,代码来源:Unpack.java


注:本文中的com.github.junrar.exception.RarException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。