本文整理汇总了Java中java.util.zip.Inflater.end方法的典型用法代码示例。如果您正苦于以下问题:Java Inflater.end方法的具体用法?Java Inflater.end怎么用?Java Inflater.end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.zip.Inflater
的用法示例。
在下文中一共展示了Inflater.end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decompress
import java.util.zip.Inflater; //导入方法依赖的package包/类
public static byte[] decompress(byte[] value) throws DataFormatException
{
ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);
Inflater decompressor = new Inflater();
try
{
decompressor.setInput(value);
final byte[] buf = new byte[1024];
while (!decompressor.finished())
{
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
} finally
{
decompressor.end();
}
return bos.toByteArray();
}
示例2: uncompress
import java.util.zip.Inflater; //导入方法依赖的package包/类
public static byte[] uncompress(final byte[] input) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Inflater decompressor = new Inflater();
try {
decompressor.setInput(input);
final byte[] buf = new byte[2048];
while (!decompressor.finished()) {
int count = 0;
try {
count = decompressor.inflate(buf);
} catch (DataFormatException e) {
e.printStackTrace();
}
bos.write(buf, 0, count);
}
} finally {
decompressor.end();
}
return bos.toByteArray();
}
示例3: b
import java.util.zip.Inflater; //导入方法依赖的package包/类
public static byte[] b(byte[] bArr) throws UnsupportedEncodingException, DataFormatException {
int i = 0;
if (bArr == null || bArr.length == 0) {
return null;
}
Inflater inflater = new Inflater();
inflater.setInput(bArr, 0, bArr.length);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr2 = new byte[1024];
while (!inflater.needsInput()) {
int inflate = inflater.inflate(bArr2);
byteArrayOutputStream.write(bArr2, i, inflate);
i += inflate;
}
inflater.end();
return byteArrayOutputStream.toByteArray();
}
示例4: inflater
import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
* 解压缩.
*
* @param inputByte byte[]数组类型的数据
* @return 解压缩后的数据
* @throws IOException
*/
public static byte[] inflater(final byte[] inputByte) throws IOException {
int compressedDataLength = 0;
Inflater compresser = new Inflater(false);
compresser.setInput(inputByte, 0, inputByte.length);
ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
byte[] result = new byte[1024];
try {
while (!compresser.finished()) {
compressedDataLength = compresser.inflate(result);
if (compressedDataLength == 0) {
break;
}
o.write(result, 0, compressedDataLength);
}
} catch (Exception ex) {
System.err.println("Data format error!\n");
ex.printStackTrace();
} finally {
o.close();
}
compresser.end();
return o.toByteArray();
}
示例5: verifyLogoutOneLogoutRequestNotAttempted
import java.util.zip.Inflater; //导入方法依赖的package包/类
@Test
public void verifyLogoutOneLogoutRequestNotAttempted() throws Exception {
final LogoutRequest logoutRequest = new DefaultLogoutRequest(TICKET_ID,
new SimpleWebApplicationServiceImpl(TEST_URL),
new URL(TEST_URL));
final Event event = getLogoutEvent(Arrays.asList(logoutRequest));
assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId());
final List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext);
assertEquals(1, list.size());
final String url = (String) event.getAttributes().get(FrontChannelLogoutAction.DEFAULT_FLOW_ATTRIBUTE_LOGOUT_URL);
assertTrue(url.startsWith(TEST_URL + "?" + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + "="));
final byte[] samlMessage = CompressionUtils.decodeBase64ToByteArray(
URLDecoder.decode(StringUtils.substringAfter(url, "?" + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + "="), "UTF-8"));
final Inflater decompresser = new Inflater();
decompresser.setInput(samlMessage);
final byte[] result = new byte[1000];
decompresser.inflate(result);
decompresser.end();
final String message = new String(result);
assertTrue(message.startsWith("<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\""));
assertTrue(message.contains("<samlp:SessionIndex>" + TICKET_ID + "</samlp:SessionIndex>"));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:24,代码来源:FrontChannelLogoutActionTests.java
示例6: decompress
import java.util.zip.Inflater; //导入方法依赖的package包/类
public static byte[] decompress(byte[] value) throws DataFormatException {
ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);
Inflater decompressor = new Inflater();
try {
decompressor.setInput(value);
final byte[] buf = new byte[1024];
while (!decompressor.finished()) {
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
} finally {
decompressor.end();
}
return bos.toByteArray();
}
示例7: onMessage
import java.util.zip.Inflater; //导入方法依赖的package包/类
@Override
public void onMessage(ByteBuffer message) {
try {
//Thanks to ShadowLordAlpha for code and debugging.
//Get the compressed message and inflate it
StringBuilder builder = new StringBuilder();
Inflater decompresser = new Inflater();
byte[] bytes = message.array();
decompresser.setInput(bytes, 0, bytes.length);
byte[] result = new byte[128];
while (!decompresser.finished()) {
int resultLength = decompresser.inflate(result);
builder.append(new String(result, 0, resultLength, "UTF-8"));
}
decompresser.end();
// send the inflated message to the TextMessage method
onMessage(builder.toString());
} catch (DataFormatException | UnsupportedEncodingException e) {
e.printStackTrace();
}
}
示例8: releaseInflater
import java.util.zip.Inflater; //导入方法依赖的package包/类
private void releaseInflater(Inflater inf) {
synchronized (inflaters) {
if (inflaters.size() < MAX_FLATER) {
inf.reset();
inflaters.add(inf);
} else {
inf.end();
}
}
}
示例9: decompressForZlib
import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
* zlib decompress 2 byte
*
* @param bytesToDecompress
* @return
*/
public static byte[] decompressForZlib(byte[] bytesToDecompress) {
byte[] returnValues = null;
Inflater inflater = new Inflater();
int numberOfBytesToDecompress = bytesToDecompress.length;
inflater.setInput(bytesToDecompress, 0, numberOfBytesToDecompress);
int numberOfBytesDecompressedSoFar = 0;
List<Byte> bytesDecompressedSoFar = new ArrayList<>();
try {
while (!inflater.needsInput()) {
byte[] bytesDecompressedBuffer = new byte[numberOfBytesToDecompress];
int numberOfBytesDecompressedThisTime = inflater.inflate(bytesDecompressedBuffer);
numberOfBytesDecompressedSoFar += numberOfBytesDecompressedThisTime;
for (int b = 0; b < numberOfBytesDecompressedThisTime; b++) {
bytesDecompressedSoFar.add(bytesDecompressedBuffer[b]);
}
}
returnValues = new byte[bytesDecompressedSoFar.size()];
for (int b = 0; b < returnValues.length; b++) {
returnValues[b] = (byte) (bytesDecompressedSoFar.get(b));
}
} catch (DataFormatException dfe) {
dfe.printStackTrace();
}
inflater.end();
return returnValues;
}
示例10: inflate
import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
* Utility method to decompress a compressed byte array.
* @param source The compressed array.
* @param off The offset in {@code source}.
* @param len The number of bytes to decompress from {@code source}.
* @return The decompressed byte array.
* @throws IOException If input array contains invalid data.
*/
public static byte[] inflate(byte[] source, int off, int len) throws IOException {
Inflater infl = new Inflater();
try {
return inflate(source, off, len, infl);
} finally {
infl.end();
}
}
示例11: ETFParser
import java.util.zip.Inflater; //导入方法依赖的package包/类
public ETFParser(byte[] data, ETFConfig config, boolean partial) {
this.expectedVersion = config.getVersion();
this.bert = config.isBert();
this.loqui = config.isLoqui();
int initialOffset = 0;
if (Byte.toUnsignedInt(data[initialOffset]) == expectedVersion) //Skip the version number
initialOffset++;
if (!partial && config.isIncludingHeader()) {
if (data[initialOffset] != HEADER)
throw new ETFException("Missing header! Is this data malformed?").withData(data, initialOffset);
initialOffset++;
long uncompressedSize = wrap(data, initialOffset, 4).getInt();
initialOffset += 4;
Inflater inflater = new Inflater();
inflater.setInput(Arrays.copyOfRange(data, initialOffset, data.length));
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
byte[] buffer = new byte[1024];
while (inflater.getBytesWritten() != uncompressedSize) {
int count = inflater.inflate(buffer);
outputStream.write(buffer, 0, count);
}
inflater.end();
outputStream.close();
this.data = outputStream.toByteArray();
} catch (Exception e) {
throw new ETFException(e).withData(data, initialOffset);
}
} else {
this.data = data;
}
}
示例12: decompressForZlib
import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
* zlib decompress 2 byte
*
* @param bytesToDecompress
* @return
*/
public static byte[] decompressForZlib(byte[] bytesToDecompress) {
byte[] returnValues = null;
Inflater inflater = new Inflater();
int numberOfBytesToDecompress = bytesToDecompress.length;
inflater.setInput(
bytesToDecompress,
0,
numberOfBytesToDecompress);
int bufferSizeInBytes = numberOfBytesToDecompress;
int numberOfBytesDecompressedSoFar = 0;
List<Byte> bytesDecompressedSoFar = new ArrayList<Byte>();
try {
while (inflater.needsInput() == false) {
byte[] bytesDecompressedBuffer = new byte[bufferSizeInBytes];
int numberOfBytesDecompressedThisTime = inflater.inflate(
bytesDecompressedBuffer);
numberOfBytesDecompressedSoFar += numberOfBytesDecompressedThisTime;
for (int b = 0; b < numberOfBytesDecompressedThisTime; b++) {
bytesDecompressedSoFar.add(bytesDecompressedBuffer[b]);
}
}
returnValues = new byte[bytesDecompressedSoFar.size()];
for (int b = 0; b < returnValues.length; b++) {
returnValues[b] = (byte) (bytesDecompressedSoFar.get(b));
}
} catch (DataFormatException dfe) {
dfe.printStackTrace();
}
inflater.end();
return returnValues;
}
示例13: decompressForZlib
import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
* zlib decompress 2 byte
*
* @param bytesToDecompress
* @return
*/
public static byte[] decompressForZlib(byte[] bytesToDecompress) {
byte[] returnValues = null;
Inflater inflater = new Inflater();
int numberOfBytesToDecompress = bytesToDecompress.length;
inflater.setInput
(bytesToDecompress, 0, numberOfBytesToDecompress);
int bufferSizeInBytes = numberOfBytesToDecompress;
int numberOfBytesDecompressedSoFar = 0;
List<Byte> bytesDecompressedSoFar = new ArrayList<Byte>();
try {
while (inflater.needsInput() == false) {
byte[] bytesDecompressedBuffer = new byte[bufferSizeInBytes];
int numberOfBytesDecompressedThisTime = inflater.inflate(bytesDecompressedBuffer);
numberOfBytesDecompressedSoFar += numberOfBytesDecompressedThisTime;
for (int b = 0; b < numberOfBytesDecompressedThisTime; b++) {
bytesDecompressedSoFar.add(bytesDecompressedBuffer[b]);
}
}
returnValues = new byte[bytesDecompressedSoFar.size()];
for (int b = 0; b < returnValues.length; b++) {
returnValues[b] = (byte) (bytesDecompressedSoFar.get(b));
}
} catch (DataFormatException dfe) {
dfe.printStackTrace();
}
inflater.end();
return returnValues;
}
示例14: decompressForZlib
import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
* zlib decompress 2 byte
*
* @param bytesToDecompress
* @return
*/
public static byte[] decompressForZlib(byte[] bytesToDecompress) {
byte[] returnValues = null;
Inflater inflater = new Inflater();
int numberOfBytesToDecompress = bytesToDecompress.length;
inflater.setInput
(
bytesToDecompress,
0,
numberOfBytesToDecompress
);
int bufferSizeInBytes = numberOfBytesToDecompress;
int numberOfBytesDecompressedSoFar = 0;
List<Byte> bytesDecompressedSoFar = new ArrayList<Byte>();
try {
while (inflater.needsInput() == false) {
byte[] bytesDecompressedBuffer = new byte[bufferSizeInBytes];
int numberOfBytesDecompressedThisTime = inflater.inflate
(
bytesDecompressedBuffer
);
numberOfBytesDecompressedSoFar += numberOfBytesDecompressedThisTime;
for (int b = 0; b < numberOfBytesDecompressedThisTime; b++) {
bytesDecompressedSoFar.add(bytesDecompressedBuffer[b]);
}
}
returnValues = new byte[bytesDecompressedSoFar.size()];
for (int b = 0; b < returnValues.length; b++) {
returnValues[b] = (byte) (bytesDecompressedSoFar.get(b));
}
} catch (DataFormatException dfe) {
dfe.printStackTrace();
}
inflater.end();
return returnValues;
}
示例15: end
import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
* Closes the (de)compressor and discards any unprocessed input. This method should be called when
* the (de)compressor is no longer being used. Once this method is called, the behavior
* De/Inflater is undefined.
*
* @see Inflater#end
* @see Deflater#end
*/
private static void end(Inflater inflater, Deflater deflater) {
inflater.end();
deflater.end();
}