- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.commons.io.input.XmlStreamReaderException.getXmlGuessEncoding()
方法的一些代码示例,展示了XmlStreamReaderException.getXmlGuessEncoding()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlStreamReaderException.getXmlGuessEncoding()
方法的具体详情如下:
包路径:org.apache.commons.io.input.XmlStreamReaderException
类名称:XmlStreamReaderException
方法名:getXmlGuessEncoding
[英]Returns the encoding guess based on the first bytes of the InputStream.
[中]返回基于InputStream的第一个字节的编码猜测。
代码示例来源:origin: commons-io/commons-io
/**
* Do lenient detection.
*
* @param httpContentType content-type header to use for the resolution of
* the charset encoding.
* @param ex The thrown exception
* @return the encoding
* @throws IOException thrown if there is a problem reading the stream.
*/
private String doLenientDetection(String httpContentType,
XmlStreamReaderException ex) throws IOException {
if (httpContentType != null && httpContentType.startsWith("text/html")) {
httpContentType = httpContentType.substring("text/html".length());
httpContentType = "text/xml" + httpContentType;
try {
return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
} catch (final XmlStreamReaderException ex2) {
ex = ex2;
}
}
String encoding = ex.getXmlEncoding();
if (encoding == null) {
encoding = ex.getContentTypeEncoding();
}
if (encoding == null) {
encoding = defaultEncoding == null ? UTF_8 : defaultEncoding;
}
return encoding;
}
代码示例来源:origin: commons-io/commons-io
private void checkRawError(final String msgSuffix,
final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final String defaultEncoding) {
try {
checkRawEncoding("XmlStreamReaderException", bomEnc, xmlGuessEnc, xmlEnc, defaultEncoding);
fail("Expected XmlStreamReaderException");
} catch (final XmlStreamReaderException e) {
assertTrue("Msg Start: " + e.getMessage(), e.getMessage().startsWith("Invalid encoding"));
assertTrue("Msg End: " + e.getMessage(), e.getMessage().endsWith(msgSuffix));
assertEquals("bomEnc", bomEnc, e.getBomEncoding());
assertEquals("xmlGuessEnc", xmlGuessEnc, e.getXmlGuessEncoding());
assertEquals("xmlEnc", xmlEnc, e.getXmlEncoding());
assertNull("ContentTypeEncoding", e.getContentTypeEncoding());
assertNull("ContentTypeMime", e.getContentTypeMime());
} catch (final Exception e) {
fail("Expected XmlStreamReaderException, but threw " + e);
}
}
代码示例来源:origin: commons-io/commons-io
private void checkHttpError(final String msgSuffix, final boolean lenient, final String httpContentType,
final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final String defaultEncoding) {
try {
checkHttpEncoding("XmlStreamReaderException", lenient, httpContentType, bomEnc, xmlGuessEnc, xmlEnc, defaultEncoding);
fail("Expected XmlStreamReaderException");
} catch (final XmlStreamReaderException e) {
assertTrue("Msg Start: " + e.getMessage(), e.getMessage().startsWith("Invalid encoding"));
assertTrue("Msg End: " + e.getMessage(), e.getMessage().endsWith(msgSuffix));
assertEquals("bomEnc", bomEnc, e.getBomEncoding());
assertEquals("xmlGuessEnc", xmlGuessEnc, e.getXmlGuessEncoding());
assertEquals("xmlEnc", xmlEnc, e.getXmlEncoding());
assertEquals("ContentTypeEncoding", XmlStreamReader.getContentTypeEncoding(httpContentType),
e.getContentTypeEncoding());
assertEquals("ContentTypeMime", XmlStreamReader.getContentTypeMime(httpContentType),
e.getContentTypeMime());
} catch (final Exception e) {
fail("Expected XmlStreamReaderException, but threw " + e);
}
}
代码示例来源:origin: Nextdoor/bender
/**
* Do lenient detection.
*
* @param httpContentType content-type header to use for the resolution of
* the charset encoding.
* @param ex The thrown exception
* @return the encoding
* @throws IOException thrown if there is a problem reading the stream.
*/
private String doLenientDetection(String httpContentType,
XmlStreamReaderException ex) throws IOException {
if (httpContentType != null && httpContentType.startsWith("text/html")) {
httpContentType = httpContentType.substring("text/html".length());
httpContentType = "text/xml" + httpContentType;
try {
return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
} catch (XmlStreamReaderException ex2) {
ex = ex2;
}
}
String encoding = ex.getXmlEncoding();
if (encoding == null) {
encoding = ex.getContentTypeEncoding();
}
if (encoding == null) {
encoding = defaultEncoding == null ? UTF_8 : defaultEncoding;
}
return encoding;
}
代码示例来源:origin: org.onosproject/onlab-thirdparty
/**
* Do lenient detection.
*
* @param httpContentType content-type header to use for the resolution of
* the charset encoding.
* @param ex The thrown exception
* @return the encoding
* @throws IOException thrown if there is a problem reading the stream.
*/
private String doLenientDetection(String httpContentType,
XmlStreamReaderException ex) throws IOException {
if (httpContentType != null && httpContentType.startsWith("text/html")) {
httpContentType = httpContentType.substring("text/html".length());
httpContentType = "text/xml" + httpContentType;
try {
return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
} catch (XmlStreamReaderException ex2) {
ex = ex2;
}
}
String encoding = ex.getXmlEncoding();
if (encoding == null) {
encoding = ex.getContentTypeEncoding();
}
if (encoding == null) {
encoding = defaultEncoding == null ? UTF_8 : defaultEncoding;
}
return encoding;
}
代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded
/**
* Do lenient detection.
*
* @param httpContentType content-type header to use for the resolution of
* the charset encoding.
* @param ex The thrown exception
* @return the encoding
* @throws IOException thrown if there is a problem reading the stream.
*/
private String doLenientDetection(String httpContentType,
XmlStreamReaderException ex) throws IOException {
if (httpContentType != null && httpContentType.startsWith("text/html")) {
httpContentType = httpContentType.substring("text/html".length());
httpContentType = "text/xml" + httpContentType;
try {
return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
} catch (final XmlStreamReaderException ex2) {
ex = ex2;
}
}
String encoding = ex.getXmlEncoding();
if (encoding == null) {
encoding = ex.getContentTypeEncoding();
}
if (encoding == null) {
encoding = defaultEncoding == null ? UTF_8 : defaultEncoding;
}
return encoding;
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* Do lenient detection.
*
* @param httpContentType content-type header to use for the resolution of
* the charset encoding.
* @param ex The thrown exception
* @return the encoding
* @throws IOException thrown if there is a problem reading the stream.
*/
private String doLenientDetection(String httpContentType,
XmlStreamReaderException ex) throws IOException {
if (httpContentType != null && httpContentType.startsWith("text/html")) {
httpContentType = httpContentType.substring("text/html".length());
httpContentType = "text/xml" + httpContentType;
try {
return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
} catch (final XmlStreamReaderException ex2) {
ex = ex2;
}
}
String encoding = ex.getXmlEncoding();
if (encoding == null) {
encoding = ex.getContentTypeEncoding();
}
if (encoding == null) {
encoding = defaultEncoding == null ? UTF_8 : defaultEncoding;
}
return encoding;
}
本文整理了Java中org.apache.commons.io.input.XmlStreamReaderException.getXmlGuessEncoding()方法的一些代码示例,展示了Xml
我是一名优秀的程序员,十分优秀!