本文整理匯總了Java中org.dom4j.io.SAXReader.setEncoding方法的典型用法代碼示例。如果您正苦於以下問題:Java SAXReader.setEncoding方法的具體用法?Java SAXReader.setEncoding怎麽用?Java SAXReader.setEncoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.dom4j.io.SAXReader
的用法示例。
在下文中一共展示了SAXReader.setEncoding方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import org.dom4j.io.SAXReader; //導入方法依賴的package包/類
/**
* 解析測試套件配置文件
* @param suiteInputStream 配置文件輸入流
* @return 測試套件對象
* @throws DocumentException
*/
public Suite parse(InputStream suiteInputStream) throws DocumentException
{
SAXReader reader = new SAXReader();
reader.setEncoding("utf-8");
Document document = reader.read(suiteInputStream);
simpleNamespaceContext.addNamespace("ns", NS_URI);
XPath xpath = new DefaultXPath("/ns:suite");
xpath.setNamespaceContext(simpleNamespaceContext);
Element suiteEle = (Element) xpath.selectSingleNode(document);
if (suiteEle == null)
{
suiteEle = document.getRootElement();
// throw new RuntimeException("Can not found suite config.");
}
Suite suite = new Suite();
String xmlConfPath = suiteEle.attributeValue("pageConfig");
String pagePackage = suiteEle.attributeValue("pagePackage", "");
String rows = suiteEle.attributeValue("rows", "1");
String lackLines = suiteEle.attributeValue("lackLines", "nearby");
String errorLines = suiteEle.attributeValue("errorLines", "stop");
String afterSleep = suiteEle.attributeValue("afterSleep", "0");
suite.setXmlConfPath(xmlConfPath);
suite.setPagePackage(pagePackage);
suite.setRows(rows);
suite.setLackLines(lackLines);
suite.setErrorLines(errorLines);
suite.setAfterSleep(Long.parseLong(afterSleep));
pagesParse(document, suite);
return suite;
}
示例2: afterPropertiesSet
import org.dom4j.io.SAXReader; //導入方法依賴的package包/類
public void afterPropertiesSet() throws Exception {
saxReader = new SAXReader();
saxReader.setEncoding("UTF-8");
httpClient = HttpClientUtils.getHttpClient();
// HttpClientUtils.testWithProxy(httpClient);
}