本文整理汇总了Java中org.tukaani.xz.XZInputStream类的典型用法代码示例。如果您正苦于以下问题:Java XZInputStream类的具体用法?Java XZInputStream怎么用?Java XZInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XZInputStream类属于org.tukaani.xz包,在下文中一共展示了XZInputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
/**
* test the correctness of the boundary condition added in new version of EnvelopeExt
*/
@Test
public void test() throws Exception{
BufferedReader in = new BufferedReader(new InputStreamReader(
new XZInputStream(new FileInputStream(
"data/polygons/counties.xz"))));
String line;
while((line = in.readLine()) != null) {
System.out.println(line.split("\\|")[0]);
String wkt = line.split("\\|")[4];
long[][] l1 = ee1.makeBorderData(wkt);
long[][] l2 = ee2.makeBorderData(wkt);
assertTrue(Arrays.deepEquals(l1, l2));
}
in.close();
}
示例2: newInput
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
@Override
protected InputService<TarDriverEntry> newInput(
final FsModel model,
final FsInputSocketSource source)
throws IOException {
final class Source extends AbstractSource {
@Override
public InputStream stream() throws IOException {
final InputStream in = source.stream();
try {
return new XZInputStream(
new BufferedInputStream(in, getBufferSize()));
} catch (final Throwable ex) {
try {
in.close();
} catch (final Throwable ex2) {
ex.addSuppressed(ex2);
}
throw ex;
}
}
} // Source
return new TarInputService(model, new Source(), this);
}
示例3: read
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
/**
*
* @param filePath
* @return
* @throws IOException
*/
static LinkedList<String> read(String filePath) throws IOException{
LinkedList<String> toReturn = new LinkedList<String>();
Scanner textInput = null;
if(filePath.endsWith(".jls_xz")){
textInput = new Scanner(new XZInputStream(new FileInputStream(filePath)));
}else if(filePath.endsWith(".jls_txt")){
textInput = new Scanner(new FileInputStream(filePath));
}else if(filePath.endsWith(".jls")){
textInput = new Scanner(new ZipInputStream(new FileInputStream(filePath)));
}else{
throw new IllegalArgumentException();
}
textInput.useDelimiter("^[ \t\n\r]*");
while(textInput.hasNext()){
toReturn.add(textInput.next());
}
textInput.close();
return toReturn;
}
示例4: decompress
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
private InputStream decompress(InputStream in) throws IOException {
PushbackInputStream pushbackIn = new PushbackInputStream(in, 2);
int b1 = pushbackIn.read();
int b2 = pushbackIn.read();
pushbackIn.unread(b2);
pushbackIn.unread(b1);
if(b1 == GzFileConnection.GZIP_MAGIC_BYTE1 && b2 == GzFileConnection.GZIP_MAGIC_BYTE2) {
return new GZIPInputStream(pushbackIn);
} else if(b1 == 0xFD && b2 == '7') {
return new XZInputStream(pushbackIn);
}
return in;
}
示例5: getXzsSymbols
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
public Symbols getXzsSymbols(Path apkPath, String libName, String xzsName, String metadataName)
throws IOException, InterruptedException {
Path xzs = unpack(apkPath, xzsName);
Path metadata = unpack(apkPath, metadataName);
Path lib = tmpDir.resolve(libName);
try (BufferedReader metadataReader = new BufferedReader(new FileReader(metadata.toFile()))) {
try (XZInputStream xzInput =
new XZInputStream(new FileInputStream(xzs.toFile()), -1, false)) {
String line = metadataReader.readLine();
while (line != null) {
String[] tokens = line.split(" ");
File metadataFile = new File(tokens[0]);
if (metadataFile.getName().equals(libName)) {
break;
}
advanceStream(xzInput, Integer.parseInt(tokens[1]));
line = metadataReader.readLine();
}
Files.copy(xzInput, lib, StandardCopyOption.REPLACE_EXISTING);
}
}
return Symbols.getDynamicSymbols(executor, objdump, resolver, lib);
}
示例6: openInputStream
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
public static DataInputStream openInputStream(String filename) throws IOException {
if (filename.endsWith(".gz")) {
return new DataInputStream(new GZIPInputStream(new FileInputStream(filename)));
} else if (filename.endsWith(".bz") || filename.endsWith(".bz2")) {
return new DataInputStream(new BZip2CompressorInputStream(new FileInputStream(filename)));
} else if(filename.endsWith(".xz")) {
return new DataInputStream(new XZInputStream(new FileInputStream(filename)));
} else {
return new DataInputStream(new FileInputStream(filename));
}
}
示例7: openInputStream
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
public static DataInputStream openInputStream(String filename) throws IOException {
if (filename.endsWith(".gz")) {
return new DataInputStream(new GZIPInputStream(new FileInputStream(filename)));
} else if (filename.endsWith(".bz") || filename.endsWith(".bz2")) {
return new DataInputStream(new BZip2CompressorInputStream(new FileInputStream(filename), true));
} else if(filename.endsWith(".xz")) {
return new DataInputStream(new XZInputStream(new FileInputStream(filename)));
} else {
return new DataInputStream(new FileInputStream(filename));
}
}
示例8: extract
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
/**
* Implement the gunzipping.
*/
@Override
protected void extract() {
if (srcResource.getLastModified() > dest.lastModified()) {
log("Expanding " + srcResource.getName() + " to "
+ dest.getAbsolutePath());
try (XZInputStream zIn =
new XZInputStream(srcResource.getInputStream());
OutputStream out = Files.newOutputStream(dest.toPath())) {
byte[] buffer = new byte[BUFFER_SIZE];
int count = 0;
do {
out.write(buffer, 0, count);
count = zIn.read(buffer, 0, buffer.length);
} while (count != -1);
} catch (IOException ioe) {
String msg = "Problem expanding xz " + ioe.getMessage();
throw new BuildException(msg, ioe, getLocation());
}
}
}
示例9: decompress
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
public static String decompress(byte[] log) throws IOException {
XZInputStream xzInputStream = new XZInputStream(
new ByteArrayInputStream(log));
byte firstByte = (byte) xzInputStream.read();
byte[] buffer = new byte[xzInputStream.available()];
buffer[0] = firstByte;
xzInputStream.read(buffer, 1, buffer.length - 2);
xzInputStream.close();
return new String(buffer);
}
示例10: getDecompressorStream
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
@Override
protected InputStream getDecompressorStream(DecompressorDescriptor descriptor)
throws IOException {
return new XZInputStream(
new BufferedInputStream(
new FileInputStream(descriptor.archivePath().getPathFile()), BUFFER_SIZE));
}
示例11: testXzStep
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
@Test
public void testXzStep() throws InterruptedException, IOException {
final Path sourceFile =
TestDataHelper.getTestDataScenario(this, "xz_with_rm_and_check").resolve("xzstep.data");
final File destinationFile = tmp.newFile("xzstep.data.xz");
XzStep step =
new XzStep(
TestProjectFilesystems.createProjectFilesystem(tmp.getRoot().toPath()),
sourceFile,
destinationFile.toPath(),
/* compressionLevel -- for faster testing */ 1,
/* keep */ true,
XZ.CHECK_CRC32);
ExecutionContext context = TestExecutionContext.newInstance();
assertEquals(0, step.execute(context).getExitCode());
ByteSource original = PathByteSource.asByteSource(sourceFile);
ByteSource decompressed =
new ByteSource() {
@Override
public InputStream openStream() throws IOException {
return new XZInputStream(new FileInputStream(destinationFile));
}
};
assertTrue(
"Decompressed file must be identical to original.", original.contentEquals(decompressed));
}
示例12: indexInputFile
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
void indexInputFile() throws IOException {
writeAndEvaluate(); // run now so we have a baseline
FileInputStream fin = new FileInputStream(input);
BufferedInputStream in = new BufferedInputStream(fin);
try (XZInputStream xzIn = new XZInputStream(in)) {
final byte[] buffer = new byte[8192];
int n;
while ((n = xzIn.read(buffer)) != -1) {
String buf = new String(buffer, 0, n); // TODO: not always correct, we need to wait for line end first?
String[] lines = buf.split("\n");
indexLine(lines);
}
}
writeAndEvaluate();
}
示例13: unGzip
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
public static InputStream unGzip(InputStream gzipArchive) throws IOException {
return new XZInputStream(gzipArchive);
}
示例14: getCompressedInputStream
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
protected InputStream getCompressedInputStream(String downloadedFile,
BufferedInputStream bufferedFileInput) throws IOException {
return new XZInputStream(bufferedFileInput);
}
示例15: setupPayloadStream
import org.tukaani.xz.XZInputStream; //导入依赖的package包/类
private InputStream setupPayloadStream () throws IOException
{
final Object payloadFormatValue = this.payloadHeader.getTag ( RpmTag.PAYLOAD_FORMAT );
final Object payloadCodingValue = this.payloadHeader.getTag ( RpmTag.PAYLOAD_CODING );
if ( payloadFormatValue != null && ! ( payloadFormatValue instanceof String ) )
{
throw new IOException ( "Payload format must be a single string" );
}
if ( payloadFormatValue != null && ! ( payloadCodingValue instanceof String ) )
{
throw new IOException ( "Payload coding must be a single string" );
}
String payloadFormat = (String)payloadFormatValue;
String payloadCoding = (String)payloadCodingValue;
if ( payloadFormat == null || payloadFormat.isEmpty () )
{
payloadFormat = "cpio";
}
if ( payloadCoding == null || payloadCoding.isEmpty () )
{
payloadCoding = "gzip";
}
if ( !"cpio".equals ( payloadFormat ) )
{
throw new IOException ( String.format ( "Unknown payload format: %s", payloadFormat ) );
}
switch ( payloadCoding )
{
case "none":
return this.in;
case "gzip":
return new GzipCompressorInputStream ( this.in );
case "bzip2":
return new BZip2CompressorInputStream ( this.in );
case "lzma":
return new LZMAInputStream ( this.in );
case "xz":
return new XZInputStream ( this.in );
default:
throw new IOException ( String.format ( "Unknown coding: %s", payloadCoding ) );
}
}