本文整理汇总了Java中java.util.zip.Deflater.DEFLATED属性的典型用法代码示例。如果您正苦于以下问题:Java Deflater.DEFLATED属性的具体用法?Java Deflater.DEFLATED怎么用?Java Deflater.DEFLATED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.zip.Deflater
的用法示例。
在下文中一共展示了Deflater.DEFLATED属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compress
static private byte[] compress(byte[] source) throws IOException
{
// ByteArrayInputStream in = new ByteArrayInputStream(source);
// ByteArrayOutputStream bous = new ByteArrayOutputStream();
// DeflaterOutputStream out = new DeflaterOutputStream(bous);
// byte[] buffer = new byte[1024];
// int len;
// while((len = in.read(buffer)) > 0) {
// out.write(buffer, 0, len);
// }
// byte[] ret = bous.toByteArray();
//
// bous.flush();
// in.close();
// out.close();
// return ret;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Deflater deflater = new Deflater(Deflater.DEFLATED);
DeflaterOutputStream deflaterStream = new DeflaterOutputStream(baos, deflater);
deflaterStream.write(source);
deflaterStream.finish();
return baos.toByteArray();
}
示例2: deflateAndBase64Encode
/**
* DEFLATE (RFC1951) compresses the given SAML message.
*
* @param message SAML message
*
* @return DEFLATE compressed message
*
* @throws MessageEncodingException thrown if there is a problem compressing the message
*/
protected String deflateAndBase64Encode(SAMLObject message) throws MessageEncodingException {
log.debug("Deflating and Base64 encoding SAML message");
try {
String messageStr = XMLHelper.nodeToString(marshallMessage(message));
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
Deflater deflater = new Deflater(Deflater.DEFLATED, true);
DeflaterOutputStream deflaterStream = new DeflaterOutputStream(bytesOut, deflater);
deflaterStream.write(messageStr.getBytes("UTF-8"));
deflaterStream.finish();
return Base64.encodeBytes(bytesOut.toByteArray(), Base64.DONT_BREAK_LINES);
} catch (IOException e) {
throw new MessageEncodingException("Unable to DEFLATE and Base64 encode SAML message", e);
}
}
示例3: deflateAndBase64Encode
/**
* DEFLATE (RFC1951) compresses the given SAML message.
*
* @param message SAML message
*
* @return DEFLATE compressed message
*
* @throws MessageEncodingException thrown if there is a problem compressing the message
*/
protected String deflateAndBase64Encode(SAMLObject message) throws MessageEncodingException {
log.debug("Deflating and Base64 encoding SAML message");
try {
String messageStr = SerializeSupport.nodeToString(marshallMessage(message));
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
Deflater deflater = new Deflater(Deflater.DEFLATED, true);
DeflaterOutputStream deflaterStream = new DeflaterOutputStream(bytesOut, deflater);
deflaterStream.write(messageStr.getBytes("UTF-8"));
deflaterStream.finish();
return Base64Support.encode(bytesOut.toByteArray(), Base64Support.UNCHUNKED);
} catch (IOException e) {
throw new MessageEncodingException("Unable to DEFLATE and Base64 encode SAML message", e);
}
}
示例4: deflateBytes
private ByteArrayOutputStream deflateBytes(ByteArrayOutputStream baos) throws IOException {
ByteArrayOutputStream deflatedBytes = new ByteArrayOutputStream();
Deflater deflater = new Deflater(Deflater.DEFLATED, true);
DeflaterOutputStream deflaterStream = new DeflaterOutputStream(deflatedBytes, deflater);
deflaterStream.write(baos.toByteArray());
deflaterStream.finish();
return deflatedBytes;
}
示例5: DeflatingStreamSinkConduit
public DeflatingStreamSinkConduit(final ConduitFactory<StreamSinkConduit> conduitFactory, final HttpServerExchange exchange) {
this(conduitFactory, exchange, Deflater.DEFLATED);
}