當前位置: 首頁>>代碼示例>>Java>>正文


Java InflaterInputStream.close方法代碼示例

本文整理匯總了Java中java.util.zip.InflaterInputStream.close方法的典型用法代碼示例。如果您正苦於以下問題:Java InflaterInputStream.close方法的具體用法?Java InflaterInputStream.close怎麽用?Java InflaterInputStream.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.zip.InflaterInputStream的用法示例。


在下文中一共展示了InflaterInputStream.close方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: inflate

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
public static byte[] inflate(InputStream stream) throws IOException {
    InflaterInputStream inputStream = new InflaterInputStream(stream);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    int length;

    try {
        while ((length = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, length);
        }
    } finally {
        buffer = outputStream.toByteArray();
        outputStream.flush();
        outputStream.close();
        inputStream.close();
    }

    return buffer;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:20,代碼來源:Zlib.java

示例2: FlateDecode

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
/** A helper to FlateDecode.
 * @param in the input data
 * @param strict <CODE>true</CODE> to read a correct stream. <CODE>false</CODE>
 * to try to read a corrupted stream
 * @return the decoded data
 */
public static byte[] FlateDecode(byte in[], boolean strict) {
    ByteArrayInputStream stream = new ByteArrayInputStream(in);
    InflaterInputStream zip = new InflaterInputStream(stream);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    byte b[] = new byte[strict ? 4092 : 1];
    try {
        int n;
        while ((n = zip.read(b)) >= 0) {
            out.write(b, 0, n);
        }
        zip.close();
        out.close();
        return out.toByteArray();
    }
    catch (Exception e) {
        if (strict)
            return null;
        return out.toByteArray();
    }
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:27,代碼來源:PdfReader.java

示例3: readScriptFile

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
public static String readScriptFile(String path) {
    String str = "";
    try {
        InflaterInputStream infis = new InflaterInputStream(new FileInputStream(path));
        ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
        int buffer;
        while ((buffer = infis.read()) != -1) {
            baos.write(buffer);
        }
        infis.close();
        baos.close();
        str = new String(baos.toByteArray());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return str;
}
 
開發者ID:Astro36,項目名稱:ModEngine,代碼行數:18,代碼來源:Utils.java

示例4: inflate

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
public static byte[] inflate(InputStream stream) throws IOException {
    InflaterInputStream inputStream = new InflaterInputStream(stream);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    int length;

    while ((length = inputStream.read(buffer)) != -1) {
        outputStream.write(buffer, 0, length);
    }

    buffer = outputStream.toByteArray();
    outputStream.flush();
    outputStream.close();
    inputStream.close();

    return buffer;
}
 
開發者ID:iTXTech,項目名稱:Nemisys,代碼行數:18,代碼來源:Zlib.java

示例5: read

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
private byte[] read(byte[] data, int pos) throws IOException
{
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ByteArrayInputStream bis = new ByteArrayInputStream(data);
    Header header = new Header();
    header.read(data, pos);
    bis.skip(pos + header.getSize());
    InflaterInputStream inflater = new InflaterInputStream(bis);
    byte[] chunk = new byte[4096];
    int count;
    while ((count = inflater.read(chunk)) >= 0)
    {
        out.write(chunk, 0, count);
    }
    inflater.close();
    return out.toByteArray();
}
 
開發者ID:iOffice1,項目名稱:iOffice,代碼行數:18,代碼來源:PICT.java

示例6: internalReadStream

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
private BufferExposingByteArrayOutputStream internalReadStream(int record) throws IOException {
  waitForPendingWriteForRecord(record);
  byte[] result;

  synchronized (myLock) {
    result = super.readBytes(record);
  }

  InflaterInputStream in = new CustomInflaterInputStream(result);
  try {
    final BufferExposingByteArrayOutputStream outputStream = new BufferExposingByteArrayOutputStream();
    StreamUtil.copyStreamContent(in, outputStream);
    return outputStream;
  }
  finally {
    in.close();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:RefCountingStorage.java

示例7: inflate

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
private static byte[] inflate(InputStream stream) throws IOException {
    InflaterInputStream inputStream = new InflaterInputStream(stream);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    int length;

    try {
        while ((length = inputStream.read(buf.get())) != -1) {
            outputStream.write(buf.get(), 0, length);
        }
    } finally {
        buf.set(outputStream.toByteArray());
        outputStream.flush();
        outputStream.close();
        inputStream.close();
    }

    return buf.get();
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:19,代碼來源:Zlib.java

示例8: b

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
public static byte[] b(byte[] bArr) {
    int i = 0;
    if (bArr == null) {
        return null;
    }
    InputStream byteArrayInputStream = new ByteArrayInputStream(bArr);
    InflaterInputStream inflaterInputStream = new InflaterInputStream(byteArrayInputStream);
    Object obj = new byte[0];
    Object obj2 = new byte[1024];
    while (true) {
        try {
            Object obj3;
            int read = inflaterInputStream.read(obj2);
            if (read > 0) {
                i += read;
                obj3 = new byte[i];
                System.arraycopy(obj, 0, obj3, 0, obj.length);
                System.arraycopy(obj2, 0, obj3, obj.length, read);
            } else {
                obj3 = obj;
            }
            if (read <= 0) {
                try {
                    byteArrayInputStream.close();
                    inflaterInputStream.close();
                    return obj3;
                } catch (IOException e) {
                    return null;
                }
            }
            obj = obj3;
        } catch (Exception e2) {
            return null;
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:37,代碼來源:j.java

示例9: inflateInputStreamTest

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
@Test
public void inflateInputStreamTest() throws IOException {
	
	File f = new File("/tmp/doc.2");
	
	InflaterInputStream iis = new InflaterInputStream(new FileInputStream(f), new Inflater());
	int i = 0, count = 0;
	while((i = iis.read()) != -1) {
		count++;
		System.out.println(i);
	}
	iis.close();
}
 
開發者ID:gncloud,項目名稱:fastcatsearch3,代碼行數:14,代碼來源:DocumentInflateTest.java

示例10: getData

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
/**
     * Extract compressed WMF data from a ppt
     */
    public byte[] getData()
    {
        try
        {
            byte[] rawdata = getRawData();

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            InputStream is = new ByteArrayInputStream(rawdata);
            is.skip(8);
            
            Header header = new Header();
            header.read(rawdata, CHECKSUM_SIZE);
            is.skip(header.getSize() + CHECKSUM_SIZE);

//            AldusHeader aldus = new AldusHeader();
//            aldus.left = header.bounds.x;
//            aldus.top = header.bounds.y;
//            aldus.right = header.bounds.x + header.bounds.width;
//            aldus.bottom = header.bounds.y + header.bounds.height;
//            aldus.write(out);

            InflaterInputStream inflater = new InflaterInputStream(is);
            byte[] chunk = new byte[4096];
            int count;
            while ((count = inflater.read(chunk)) >= 0)
            {
                out.write(chunk, 0, count);
            }
            inflater.close();
            return out.toByteArray();
        }
        catch(IOException e)
        {
            throw new HSLFException(e);
        }
    }
 
開發者ID:iOffice1,項目名稱:iOffice,代碼行數:40,代碼來源:WMF.java

示例11: getData

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
/**
 * Extract compressed EMF data from a ppt
 */
public byte[] getData()
{
    try
    {
        byte[] rawdata = getRawData();

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        InputStream is = new ByteArrayInputStream(rawdata);
        is.skip(8);
        
        Header header = new Header();
        header.read(rawdata, CHECKSUM_SIZE);
        is.skip(header.getSize() + CHECKSUM_SIZE);

        InflaterInputStream inflater = new InflaterInputStream(is);
        byte[] chunk = new byte[4096];
        int count;
        while ((count = inflater.read(chunk)) >= 0)
        {
            out.write(chunk, 0, count);
        }
        inflater.close();
        return out.toByteArray();
    }
    catch(IOException e)
    {
        throw new HSLFException(e);
    }
}
 
開發者ID:iOffice1,項目名稱:iOffice,代碼行數:33,代碼來源:EMF.java

示例12: writeByte_WMFAndEMF

import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
public void writeByte_WMFAndEMF(FileOutputStream out)
{
	try
    {
        byte[] rawdata = getRawData();

        InputStream is = new ByteArrayInputStream(rawdata);
        is.skip(8);
        
        Header header = new Header();
        header.read(rawdata, CHECKSUM_SIZE);
        is.skip(header.getSize() + CHECKSUM_SIZE);

        InflaterInputStream inflater = new InflaterInputStream(is);
        byte[] chunk = new byte[4096];
        int count;
        while ((count = inflater.read(chunk)) >= 0)
        {
            out.write(chunk, 0, count);
        }
        inflater.close();
    }
    catch(IOException e)
    {
        throw new HSLFException(e);
    }
}
 
開發者ID:iOffice1,項目名稱:iOffice,代碼行數:28,代碼來源:Metafile.java


注:本文中的java.util.zip.InflaterInputStream.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。