本文整理汇总了Java中com.amazonaws.util.StringUtils.UTF8属性的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.UTF8属性的具体用法?Java StringUtils.UTF8怎么用?Java StringUtils.UTF8使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.amazonaws.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.UTF8属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: from
private static String from(InputStream is) throws IOException {
if (is == null)
return "";
StringBuilder sb = new StringBuilder();
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(is, StringUtils.UTF8));
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} finally {
is.close();
}
return sb.toString();
}
示例2: convertStreamToString
/**
* Converts the contents of an input stream to a String
*/
private static String convertStreamToString(InputStream inputStream)
throws IOException {
if (inputStream == null) {
return "";
} else {
StringBuilder stringBuilder = new StringBuilder();
String line;
try {
BufferedReader reader =
new BufferedReader(new InputStreamReader(inputStream,
StringUtils.UTF8));
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
}
} finally {
inputStream.close();
}
return stringBuilder.toString();
}
}
示例3: loadAndReplaceMimetypes
/**
* Reads and stores the mime type setting corresponding to a file extension, by reading
* text from an InputStream. If a mime type setting already exists when this method is run,
* the mime type value is replaced with the newer one.
*
* @param is
*
* @throws IOException
*/
public void loadAndReplaceMimetypes(InputStream is) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(is,
StringUtils.UTF8));
String line = null;
while ((line = br.readLine()) != null) {
line = line.trim();
if (line.startsWith("#") || line.length() == 0) {
// Ignore comments and empty lines.
} else {
StringTokenizer st = new StringTokenizer(line, " \t");
if (st.countTokens() > 1) {
String mimetype = st.nextToken();
while (st.hasMoreTokens()) {
String extension = st.nextToken();
extensionToMimetypeMap.put(StringUtils.lowerCase(extension), mimetype);
if (log.isDebugEnabled()) {
log.debug("Setting mime type for extension '" + StringUtils.lowerCase(extension) + "' to '" + mimetype + "'");
}
}
} else {
if (log.isDebugEnabled()) {
log.debug("Ignoring mimetype with no associated file extensions: '" + line + "'");
}
}
}
}
}
示例4: getRawResponseContent
/**
* Typically only useful for debugging purpose if for some reason the SDK cannot parse the HTTP
* response from a service
*
* @return The raw content of the HTTP response as a String.
*/
public String getRawResponseContent() {
return rawResponse == null ? null : new String(rawResponse, StringUtils.UTF8);
}