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


Java Inflater.setInput方法代码示例

本文整理汇总了Java中java.util.zip.Inflater.setInput方法的典型用法代码示例。如果您正苦于以下问题:Java Inflater.setInput方法的具体用法?Java Inflater.setInput怎么用?Java Inflater.setInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.zip.Inflater的用法示例。


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

示例1: testLogoutOneLogoutRequestNotAttempted

import java.util.zip.Inflater; //导入方法依赖的package包/类
@Test
public void testLogoutOneLogoutRequestNotAttempted() throws Exception {
    final String FAKE_URL = "http://url";
    LogoutRequest logoutRequest = new LogoutRequest(TICKET_ID, new SimpleWebApplicationServiceImpl(FAKE_URL));
    WebUtils.putLogoutRequests(this.requestContext, Arrays.asList(logoutRequest));
    this.requestContext.getFlowScope().put(FrontChannelLogoutAction.LOGOUT_INDEX, 0);
    final Event event = this.frontChannelLogoutAction.doExecute(this.requestContext);
    assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId());
    List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext);
    assertEquals(1, list.size());
    final String url = (String) event.getAttributes().get("logoutUrl");
    assertTrue(url.startsWith(FAKE_URL + "?SAMLRequest="));
    final byte[] samlMessage = Base64.decodeBase64(URLDecoder.decode(StringUtils.substringAfter(url,  "?SAMLRequest="), "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.indexOf("<samlp:SessionIndex>" + TICKET_ID + "</samlp:SessionIndex>") >= 0);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:23,代码来源:FrontChannelLogoutActionTests.java

示例2: 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();
	}
}
 
开发者ID:discord-java,项目名称:discord.jar,代码行数:24,代码来源:WebSocketClient.java

示例3: uncompress

import java.util.zip.Inflater; //导入方法依赖的package包/类
@Override
public byte[] uncompress(byte[] data) throws IOException {
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	Inflater decompressor = new Inflater();
	
	try {
		decompressor.setInput(data);
		final byte[] buf = new byte[2048];
		while (!decompressor.finished()) {
			int count = decompressor.inflate(buf);
			bos.write(buf, 0, count);
		}
	} catch (DataFormatException e) {
		e.printStackTrace();
	} finally {
		decompressor.end();
	}
	
	return bos.toByteArray();
}
 
开发者ID:yu120,项目名称:compress,代码行数:21,代码来源:DeflaterCompress.java

示例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();
}
 
开发者ID:howe,项目名称:nutz-pay,代码行数:31,代码来源:SDKUtil.java

示例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: decodeURLBase64DeflateString

import java.util.zip.Inflater; //导入方法依赖的package包/类
private String decodeURLBase64DeflateString(final String input)
        throws UnsupportedEncodingException, DataFormatException {
    String urlDecoded = URLDecoder.decode(input, "UTF-8");
    byte[] base64Decoded = Base64.decodeBase64(urlDecoded);

    Inflater decompresser = new Inflater(true);
    decompresser.setInput(base64Decoded);
    StringBuilder result = new StringBuilder();

    while (!decompresser.finished()) {
        byte[] outputFraction = new byte[base64Decoded.length];
        int resultLength = decompresser.inflate(outputFraction);
        result.append(new String(outputFraction, 0, resultLength, "UTF-8"));
    }

    return result.toString();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:RedirectEncoderTest.java

示例7: inflate

import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
 * Inflate the given byte array by {@link #INFLATED_ARRAY_LENGTH}.
 *
 * @param bytes the bytes
 * @return the array as a string with {@code UTF-8} encoding
 */
public static String inflate(final byte[] bytes) {
    final Inflater inflater = new Inflater(true);
    final byte[] xmlMessageBytes = new byte[INFLATED_ARRAY_LENGTH];

    final byte[] extendedBytes = new byte[bytes.length + 1];
    System.arraycopy(bytes, 0, extendedBytes, 0, bytes.length);
    extendedBytes[bytes.length] = 0;

    inflater.setInput(extendedBytes);

    try {
        final int resultLength = inflater.inflate(xmlMessageBytes);
        inflater.end();

        if (!inflater.finished()) {
            throw new RuntimeException("buffer not large enough.");
        }

        inflater.end();
        return new String(xmlMessageBytes, 0, resultLength, StandardCharsets.UTF_8);
    } catch (final DataFormatException e) {
        return null;
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:31,代码来源:CompressionUtils.java

示例8: decompress

import java.util.zip.Inflater; //导入方法依赖的package包/类
/** Decompress the byte array previously returned by
 *  compress */
public static byte[] decompress(byte[] value, int offset, int length) throws DataFormatException {
  // Create an expandable byte array to hold the decompressed data
  ByteArrayOutputStream bos = new ByteArrayOutputStream(length);

  Inflater decompressor = new Inflater();

  try {
    decompressor.setInput(value, offset, length);

    // Decompress the data
    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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:CompressionTools.java

示例9: uncompress

import java.util.zip.Inflater; //导入方法依赖的package包/类
public static byte[] uncompress(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();
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:21,代码来源:LogUtils.java

示例10: decompress

import java.util.zip.Inflater; //导入方法依赖的package包/类
static byte[] decompress(byte[] bytesIn, int offset) throws Exception {
    Inflater inflater = new Inflater();
    inflater.setInput(bytesIn, offset, bytesIn.length - offset);
    ByteArrayOutputStream stream = new ByteArrayOutputStream(bytesIn.length - offset);
    byte[] buffer = new byte[1024];

    while (!inflater.finished()) {
        int count = inflater.inflate(buffer);
        stream.write(buffer, 0, count);
    }

    stream.close();

    byte[] bytesOut = stream.toByteArray();
    inflater.end();

    return bytesOut;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ZipDecompressor.java

示例11: deflate

import java.util.zip.Inflater; //导入方法依赖的package包/类
/** Descomprime un certificado contenido en la tarjeta CERES.
 * @param compressedCertificate Certificado comprimido en ZIP a partir del 9 octeto.
 * @return Certificado codificado.
 * @throws IOException Cuando se produce un error en la descompresi&oacute;n del certificado. */
private static byte[] deflate(final byte[] compressedCertificate) throws IOException {
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    final Inflater decompressor = new Inflater();
    decompressor.setInput(compressedCertificate, 8, compressedCertificate.length - 8);
    final byte[] buf = new byte[1024];
    try {
        // Descomprimimos los datos
        while (!decompressor.finished()) {
            final int count = decompressor.inflate(buf);
            if (count == 0) {
                throw new DataFormatException();
            }
            buffer.write(buf, 0, count);
        }
        // Obtenemos los datos descomprimidos
        return buffer.toByteArray();
    }
    catch (final DataFormatException ex) {
        throw new IOException("Error al descomprimir el certificado: " + ex, ex); //$NON-NLS-1$
    }
}
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:26,代码来源:Ceres.java

示例12: 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();
  }
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:21,代码来源:BiliDanmukuCompressionTools.java

示例13: decompressToString

import java.util.zip.Inflater; //导入方法依赖的package包/类
public static String decompressToString(String base64String) throws UnsupportedEncodingException, DataFormatException
{
    byte[] compressedData = Base64.decodeBase64(base64String);

    Inflater deCompressor = new Inflater();
    deCompressor.setInput(compressedData, 0, compressedData.length);
    byte[] output = new byte[1024];
    int decompressedDataLength = deCompressor.inflate(output);
    deCompressor.end();

    return new String(output, 0, decompressedDataLength, "UTF-8");
}
 
开发者ID:tmobile,项目名称:keybiner,代码行数:13,代码来源:Compression.java

示例14: refillInflater

import java.util.zip.Inflater; //导入方法依赖的package包/类
private void refillInflater(Inflater inflater) throws IOException {
    while(chunkRemaining == 0) {
        closeChunk();
        openChunk(IDAT);
    }
    int read = readChunk(buffer, 0, buffer.length);
    inflater.setInput(buffer, 0, read);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:9,代码来源:PNGDecoder.java

示例15: inflate

import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
 * Utility method to decompress a compressed byte array, using the given {@link Inflater}.
 * @param source The compressed array.
 * @param off The offset in {@code source}.
 * @param len The number of bytes in {@code source}.
 * @param infl The inflater to use for decompression.
 * @return The decompressed byte array.
 * @throws IOException If input array contains invalid data.
 */
public static byte[] inflate(byte[] source, int off, int len, Inflater infl) throws IOException {
	infl.setInput(source, off, len);
	byte[] buf = new byte[1024];
	try (DirectByteArrayOutputStream bos = new DirectByteArrayOutputStream(buf.length)) {
		int n;
		while ((n = infl.inflate(buf)) > 0)
			bos.write(buf, 0, n);
		return Arrays.copyOf(bos.toByteArray(), bos.size());
	} catch (DataFormatException e) {
		throw new IOException("Cannot inflate data: "+e.getMessage(), e);
	}
}
 
开发者ID:matthieu-labas,项目名称:JRF,代码行数:22,代码来源:Utils.java


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