本文整理汇总了Java中org.jets3t.service.Constants.DEFAULT_ENCODING属性的典型用法代码示例。如果您正苦于以下问题:Java Constants.DEFAULT_ENCODING属性的具体用法?Java Constants.DEFAULT_ENCODING怎么用?Java Constants.DEFAULT_ENCODING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.jets3t.service.Constants
的用法示例。
在下文中一共展示了Constants.DEFAULT_ENCODING属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseXmlInputStream
/**
* Parses an XML document from an input stream using a document handler.
* @param handler
* the handler for the XML document
* @param inputStream
* an input stream containing the XML document to parse
* @throws S3ServiceException
* any parsing, IO or other exceptions are wrapped in an S3ServiceException.
*/
protected void parseXmlInputStream(DefaultHandler handler, InputStream inputStream)
throws CloudFrontServiceException
{
try {
if (log.isDebugEnabled()) {
log.debug("Parsing XML response document with handler: " + handler.getClass());
}
BufferedReader breader = new BufferedReader(new InputStreamReader(inputStream,
Constants.DEFAULT_ENCODING));
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
xr.parse(new InputSource(breader));
} catch (Throwable t) {
try {
inputStream.close();
} catch (IOException e) {
if (log.isErrorEnabled()) {
log.error("Unable to close response InputStream up after XML parse failure", e);
}
}
throw new CloudFrontServiceException("Failed to parse XML document with handler "
+ handler.getClass(), t);
}
}
示例2: parseXmlInputStream
/**
* Parses an XML document from an input stream using a document handler.
* @param handler
* the handler for the XML document
* @param inputStream
* an input stream containing the XML document to parse
* @throws ServiceException
* any parsing, IO or other exceptions are wrapped in an ServiceException.
*/
protected void parseXmlInputStream(DefaultHandler handler, InputStream inputStream)
throws ServiceException
{
try {
if (log.isDebugEnabled()) {
log.debug("Parsing XML response document with handler: " + handler.getClass());
}
BufferedReader breader = new BufferedReader(
new InputStreamReader(inputStream, Constants.DEFAULT_ENCODING));
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
xr.parse(new InputSource(breader));
inputStream.close();
} catch (Throwable t) {
try {
inputStream.close();
} catch (IOException e) {
if (log.isErrorEnabled()) {
log.error("Unable to close response InputStream up after XML parse failure", e);
}
}
throw new ServiceException("Failed to parse XML document with handler "
+ handler.getClass(), t);
}
}
示例3: createBucketImpl
@Override
protected StorageBucket createBucketImpl(String bucketName, String location,
AccessControlList acl, Map<String, Object> headers)
throws ServiceException
{
if (log.isDebugEnabled()) {
log.debug("Creating bucket with name: " + bucketName);
}
Map<String, Object> metadata = new HashMap<String, Object>();
metadata.putAll(headers);
HttpEntity requestEntity = null;
if (location != null && !"US".equalsIgnoreCase(location)) {
metadata.put("Content-Type", "text/xml");
try {
CreateBucketConfiguration config = new CreateBucketConfiguration(location);
String configXml = config.toXml();
metadata.put("Content-Length", String.valueOf(configXml.length()));
requestEntity = new StringEntity(configXml, "text/xml", Constants.DEFAULT_ENCODING);
} catch (Exception e) {
throw new ServiceException("Unable to encode CreateBucketConfiguration XML document", e);
}
}
Map<String, Object> map = createObjectImpl(bucketName, null, null,
requestEntity, metadata, null, acl, null, null);
StorageBucket bucket = newBucket();
bucket.setName(bucketName);
bucket.setLocation(location);
bucket.setAcl(acl);
bucket.replaceAllMetadata(map);
return bucket;
}
示例4: sanitizeXmlDocument
protected InputStream sanitizeXmlDocument(DefaultHandler handler, InputStream inputStream)
throws ServiceException
{
if (!properties.getBoolProperty("xmlparser.sanitize-listings", true)) {
// No sanitizing will be performed, return the original input stream unchanged.
return inputStream;
} else {
if (log.isDebugEnabled()) {
log.debug("Sanitizing XML document destined for handler " + handler.getClass());
}
InputStream sanitizedInputStream = null;
try {
/* Read object listing XML document from input stream provided into a
* string buffer, so we can replace troublesome characters before
* sending the document to the XML parser.
*/
StringBuilder listingDocBuffer = new StringBuilder();
BufferedReader br = new BufferedReader(
new InputStreamReader(inputStream, Constants.DEFAULT_ENCODING));
char[] buf = new char[8192];
int read = -1;
while ((read = br.read(buf)) != -1) {
listingDocBuffer.append(buf, 0, read);
}
br.close();
// Replace any carriage return (\r) characters with explicit XML
// character entities, to prevent the SAX parser from
// misinterpreting 0x0D characters as 0x0A.
String listingDoc = listingDocBuffer.toString().replaceAll("\r", "
");
sanitizedInputStream = new ByteArrayInputStream(
listingDoc.getBytes(Constants.DEFAULT_ENCODING));
} catch (Throwable t) {
try {
inputStream.close();
} catch (IOException e) {
if (log.isErrorEnabled()) {
log.error("Unable to close response InputStream after failure sanitizing XML document", e);
}
}
throw new ServiceException("Failed to sanitize XML document destined for handler "
+ handler.getClass(), t);
}
return sanitizedInputStream;
}
}
示例5: decryptString
/**
* Decrypts byte data to a UTF-8 string.
*
* @param data
* data to decrypt.
* @return
* UTF-8 string of decrypted data.
*
* @throws InvalidKeyException
* @throws InvalidAlgorithmParameterException
* @throws UnsupportedEncodingException
* @throws IllegalStateException
* @throws IllegalBlockSizeException
* @throws BadPaddingException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
*/
public String decryptString(byte[] data) throws InvalidKeyException,
InvalidAlgorithmParameterException, UnsupportedEncodingException, IllegalStateException,
IllegalBlockSizeException, BadPaddingException, NoSuchAlgorithmException, NoSuchPaddingException
{
Cipher cipher = initEncryptModeCipher();
return new String(cipher.doFinal(data), Constants.DEFAULT_ENCODING);
}