本文整理匯總了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);
}