java saxreader 字符串_Java SAXReader.read方法代碼示例

java saxreader 字符串_Java SAXReader.read方法代碼示例本文整理匯總了Java中org.dom4j.io.SAXReader.read方法的典型用法代碼示例。如果您正苦於以下問題:JavaSAXReader.read方法的具體用法?JavaSAXReader.read怎麽用?JavaSAXReader.read使用的例子?那麽恭喜您,這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.dom4j.io.SAXRea…

大家好,又见面了,我是你们的朋友全栈君。

本文整理匯總了Java中org.dom4j.io.SAXReader.read方法的典型用法代碼示例。如果您正苦於以下問題:Java SAXReader.read方法的具體用法?Java SAXReader.read怎麽用?Java SAXReader.read使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.dom4j.io.SAXReader的用法示例。

在下文中一共展示了SAXReader.read方法的17個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: testdeployDefinition

​點讚 4

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

@Test

public void testdeployDefinition() {

// 初始化

SAXReader reader = new SAXReader();

// 拿不到信息

URL url = this.getClass().getResource(“/process12.xml”);

Document document = null;

try {

document = reader.read(url);

} catch (DocumentException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

String definitionContent = document.asXML();

// deploy first time

DefinitionHelper.getInstance().deployDefinition(“process”, “測試流程”, definitionContent, true);

}

開發者ID:alibaba,項目名稱:bulbasaur,代碼行數:20,

示例2: getFieldDefines

​點讚 3

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

private static Map getFieldDefines(File file, InputStream inputStream, Reader reader) {

SAXReader saxReader = new SAXReader();

Document document = null;

try {

if (file != null) {

document = saxReader.read(file);

} else if (inputStream != null) {

document = saxReader.read(inputStream);

} else if (reader != null) {

document = saxReader.read(reader);

} else {

throw new IllegalArgumentException(“all arguments is null”);

}

} catch (DocumentException e) {

throw new IllegalArgumentException(e);

}

return parseRootElements(document.getRootElement());

}

開發者ID:brucezee,項目名稱:jspider,代碼行數:19,

示例3: getValidDrcPathways

​點讚 3

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

/**

* Return a HasMap of valid DRC pathways from the pathways.xsd schema. Both the keys and values cantain the

* exact Strings of the valid pathways.

*

* @return HashMap of valid DRC pathways.

*/

private HashMap getValidDrcPathways() {

if (annotationPathwaysSchemaUrl == null)

return null;

HashMap pathways = new HashMap();

try {

SAXReader reader = new SAXReader();

Document document = reader.read(new URL(annotationPathwaysSchemaUrl));

List nodes = document.selectNodes(“//xsd:simpleType[@name=’pathwayType’]/xsd:restriction/xsd:enumeration”);

for (Iterator iter = nodes.iterator(); iter.hasNext(); ) {

Node node = (Node) iter.next();

pathways.put(node.valueOf(“@value”), node.valueOf(“@value”));

}

} catch (Throwable e) {

prtlnErr(“Error getValidDrcPathways(): ” + e);

}

return pathways;

}

開發者ID:NCAR,項目名稱:joai-project,代碼行數:28,

示例4: generate

​點讚 3

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

void generate(File findbugsFile, File messageFile, File output, String[] tags) throws IOException {

SAXReader reader = new SAXReader();

try {

Document message = reader.read(messageFile);

Document findbugs = reader.read(findbugsFile);

@SuppressWarnings(“unchecked”)

List bugPatterns = message.selectNodes(“/MessageCollection/BugPattern”);

@SuppressWarnings(“unchecked”)

List findbugsAbstract = findbugs.selectNodes(“/FindbugsPlugin/BugPattern”);

writePatterns(findbugsAbstract, bugPatterns, output, tags);

} catch (DocumentException e) {

throw new IllegalArgumentException(e);

}

}

開發者ID:KengoTODA,項目名稱:sonarqube-rule-xml-generator,代碼行數:17,

示例5: createReader

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

/**

* @since 1.4

*/

@Override

public HierarchicalStreamReader createReader(final URL in) {

try {

final SAXReader reader = new SAXReader();

final Document document = reader.read(in);

return new Dom4JReader(document, getNameCoder());

} catch (final DocumentException e) {

throw new StreamException(e);

}

}

開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,

示例6: readDocument

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

private Document readDocument(String path, ActionLog actionLog) throws DocumentException{

SAXReader reader=new SAXReader();

Document logDocument=reader.read(path);

Element log=logDocument.getRootElement();

Element action=log.addElement(“action”);

action.addElement(“name”).addText(actionLog.getName());

action.addElement(“s-time”).addText(actionLog.getStartTime().toString());

action.addElement(“e-time”).addText(actionLog.getEndTime().toString());

action.addElement(“result”).addText(actionLog.getResult());

System.out.println(“Write “+log.getName());

System.out.println(path);

return logDocument;

}

開發者ID:Hang-Hu,項目名稱:SimpleController,代碼行數:14,

示例7: loadXML

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

/**

* Load XML File, Read it into Document

* @param filename

* The Name of the file which will be analysis

*/

public Document loadXML(final String filename)

{

//Document document = null;

try

{

final SAXReader saxReader = new SAXReader();

document = saxReader.read(new File(filename));

}

catch (final Exception ex)

{

ex.printStackTrace();

}

return document;

}

開發者ID:ansleliu,項目名稱:GraphicsViewJambi,代碼行數:20,

示例8: getXML

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

/**

* 從文件讀取XML,輸入文件名,返回XML文檔

*

* @param processName

* @param processVersion

* @return Document

* @since 2012-12-27 下午06:52:23

*/

public Document getXML(String processName, @SuppressWarnings(“UnusedParameters”) int processVersion) {

SAXReader reader = new SAXReader();

URL url = this.getClass().getResource(“/” + processName.replaceAll(“\\.”, “/”) + “.xml”);

Document document;

try {

document = reader.read(url);

} catch (Exception e) {

logger.error(“xml流程文件讀取失敗!模板名:” + processName);

throw new NullPointerException(“xml流程文件讀取失敗!模板名:” + processName + “\n” + e);

}

return document;

}

開發者ID:alibaba,項目名稱:bulbasaur,代碼行數:23,

示例9: doPost

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

response.setContentType(“text/html;charset=UTF-8”);

request.setCharacterEncoding(“UTF-8”);

//獲取HTTP請求的輸入流

InputStream is = request.getInputStream();

//已HTTP請求輸入流建立一個BufferedReader對象

BufferedReader br = new BufferedReader(new InputStreamReader(is,”UTF-8″));

StringBuilder sb = new StringBuilder();

//讀取HTTP請求內容

String buffer = null;

while ((buffer = br.readLine()) != null) {

sb.append(buffer);

}

String content = sb.toString().substring(sb.toString().indexOf(“<?xml “), sb.toString().indexOf(“”)+8);

System.out.println(content);

// 創建xml解析對象

SAXReader reader = new SAXReader();

// 定義一個文檔

Document document = null;

//將字符串轉換為

try {

document = reader.read(new ByteArrayInputStream(content.getBytes(“GBK”)));

} catch (DocumentException e) {

e.printStackTrace();

}

//response.setStatus(302);//設置302狀態碼,等同於response.setStatus(302);

//response.sendRedirect(“http://192.168.1.106:8080/udid?UDID=2123”);

//response.setStatus(HttpServletResponse.SC_FOUND);

response.setHeader(“Location”, “http://192.168.1.106:8080/udid.jsp?UDID=2123”);

response.setStatus(301);

}

開發者ID:shaojiankui,項目名稱:iOS-UDID-Safari,代碼行數:39,

示例10: parseXml

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

protected Element parseXml(InputStream stream){

SAXReader reader=new SAXReader();

Document document;

try {

document = reader.read(stream);

Element root=document.getRootElement();

return root;

} catch (DocumentException e) {

throw new RuleException(e);

}

}

開發者ID:youseries,項目名稱:urule,代碼行數:12,

示例11: XMLFile

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

public XMLFile(String filename) throws DocumentException, MalformedURLException {

this.filename = filename;

File file = new File(filename);

SAXReader saxReader = new SAXReader();

this.document = saxReader.read(file);

}

開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:8,

示例12: readXML

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

private Element readXML(String path){

SAXReader reader=new SAXReader();

Document document= null;

try {

document = reader.read(path);

} catch (DocumentException e) {

e.printStackTrace();

}

Element root=document.getRootElement();

return root;

}

開發者ID:Hang-Hu,項目名稱:SimpleController,代碼行數:12,

示例13: of

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

public static XmlParser of(Reader reader) throws DocumentException {

SAXReader saxReader = new SAXReader();

Document doc = saxReader.read(reader);

return new XmlParser(doc);

}

開發者ID:flapdoodle-oss,項目名稱:de.flapdoodle.solid,代碼行數:7,

示例14: getConfig

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

/**

* 獲取配置

*

* @param name

* @return

* @throws Exception

*/

public static HttpConfig getConfig(String name) throws Exception {

HttpConfig hc = CONFIG_MAP.get(name);

if (hc == null) {

SAXReader reader = new SAXReader();

File xml = new File(HTTP_CONFIG_FILE);

Document doc;

Element root;

if (xml.exists()) {

try (FileInputStream in = new FileInputStream(xml); Reader read = new InputStreamReader(in, “UTF-8”)) {

doc = reader.read(read);

root = doc.getRootElement();

List els = root.selectNodes(“/root/configs/config”);

for (Element el : els) {

String nameStr = el.attributeValue(“name”);

String encodeType = el.attributeValue(“encodeType”);

String charset = el.attributeValue(“charset”);

String requestType = el.attributeValue(“requestType”);

String sendXML = el.attributeValue(“sendXML”);

String packHead = el.attributeValue(“packHead”);

String lowercaseEncode = el.attributeValue(“lowercaseEncode”);

String url = el.elementTextTrim(“url”);

String header = el.elementTextTrim(“header”);

String parameter = el.elementTextTrim(“parameter”);

String encodeField = el.elementTextTrim(“encodeField”);

String encodeKey = el.elementTextTrim(“encodeKey”);

String contentType = el.elementTextTrim(“contentType”);

HttpConfig config = new HttpConfig(nameStr, url, charset, header, parameter, requestType, contentType);

config.setSendXML(Boolean.valueOf(sendXML));

config.setEncodeKey(encodeKey);

config.setEncodeType(encodeType);

config.setEncodeFieldName(encodeField);

config.setLowercaseEncode(Boolean.valueOf(lowercaseEncode));

config.setPackHead(Boolean.valueOf(packHead));

CONFIG_MAP.put(nameStr, config);

if (nameStr.equals(name)) {

hc = config;

}

}

}

}

}

return hc;

}

開發者ID:ajtdnyy,項目名稱:PackagePlugin,代碼行數:52,

示例15: readRecipe

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

protected void readRecipe(String xml) {

try {

SAXReader reader = new SAXReader();

DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();

domFactory.setNamespaceAware(true); // never forget this!

org.xml.sax.InputSource inStream = new org.xml.sax.InputSource();

inStream.setCharacterStream(new java.io.StringReader(xml));

Document doc = reader.read(inStream);

Element root = doc.getRootElement();

List nodes = root.elements();

for (int i = 0; i < nodes.size(); i++) {

Element element = (Element) nodes.get(i);

if (element.getName().equals(“recipe_id”)) {

this.setRecipeId(Integer.parseInt(element.getText()));

}

else if (element.getName().equals(“recipe_name”)) {

this.setName(element.getText());

}

else if (element.getName().equals(“recipe_url”)) {

this.setRecipeUrl(element.getText());

}

else if (element.getName().equals(“rating”)) {

if(!element.getText().contains(“NaN”)) {

this.setRating(Integer.parseInt(element.getText()));

}

else {

this.setRating(0);

}

}

else if (element.getName().equals(“serving_sizes”)) {

this.calories = Integer.parseInt(element.element(“serving”).element(“calories”).getText());

}

else if (element.getName().equals(“recipe_images”)) {

this.setImageUrl(element.element(“recipe_image”).getText());

}

else if (element.getName().equals(“preparation_time_min”)) {

this.setPreparationTime(Double.parseDouble(element.getText()));

}

else if (element.getName().equals(“cooking_time_min”)) {

this.setCookingTime(Double.parseDouble(element.getText()));

}

else if (element.getName().equals(“ingredients”)) {

List ings = element.elements();

int foodId = 0;

String foodName = “”;

for(int j=0;j

{

Element ingredient = (Element) ings.get(j);

foodId = Integer.parseInt(ingredient.element(“food_id”).getText());

foodName = ingredient.element(“food_name”).getText();

Ingredient ing = new Ingredient(foodId,foodName);

ingredients.add(ing);

}

}

else if (element.getName().equals(“directions”)) {

List dirs = element.elements();

for (int j = 0; j

Element direct = (Element) dirs.get(j).element(“direction_description”);

directions.add(direct.getText());

}

}

}

} catch (Exception e) {

e.printStackTrace();

System.err.println(e);

}

}

開發者ID:aysenurbilgin,項目名稱:cww_framework,代碼行數:74,

示例16: processLog

​點讚 2

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

/**

* Concrete processing.

*

* @throws IOException

*/

protected void processLog() throws IOException {

final List tempFiles = new LinkedList();

try {

// check if it’s a directory

if (!super.agent.pathIsFile(fullyQualifiedResultPath)) {

reportLogPathIsNotFile();

return;

}

// get log and make an archive copy

final String archiveFileName = archiveManager.makeNewLogFileNameOnly(); // just a file name, w/o path

final File archiveFile = archiveManager.fileNameToLogPath(archiveFileName);

agent.readFile(super.fullyQualifiedResultPath, archiveFile);

// check if any

if (!archiveFile.exists()) {

return;

}

// save log info in the db if necessary

// parse

if (log.isDebugEnabled()) {

log.debug(“parse “);

}

final SAXReader reader = new SAXReader();

final Document checkstyle = reader.read(archiveFile);

// get and save

if (log.isDebugEnabled()) {

log.debug(“get statistics “);

}

final int problemFileCount = XMLUtils.intValueOf(checkstyle, “count(/checkstyle/file[count(error) > 0])”);

final int fileCount = XMLUtils.intValueOf(checkstyle, “count(/checkstyle/file)”);

final int problemCount = XMLUtils.intValueOf(checkstyle, “count(/checkstyle/file/error)”);

cm.addStepStatistics(super.stepRunID, StepRunAttribute.ATTR_CHECKSTYLE_ERRORS, problemCount);

cm.addStepStatistics(super.stepRunID, StepRunAttribute.ATTR_CHECKSTYLE_FILES_WITH_PROBLEMS, problemFileCount);

cm.addStepStatistics(super.stepRunID, StepRunAttribute.ATTR_CHECKSTYLE_FILES, fileCount);

cm.addRunStatistics(buildRunID, BuildRunAttribute.ATTR_CHECKSTYLE_ERRORS, problemCount);

cm.addRunStatistics(buildRunID, BuildRunAttribute.ATTR_CHECKSTYLE_FILES_WITH_PROBLEMS, problemFileCount);

cm.addRunStatistics(buildRunID, BuildRunAttribute.ATTR_CHECKSTYLE_FILES, fileCount);

// save log info

final StepLog stepLog = new StepLog();

stepLog.setStepRunID(super.stepRunID);

stepLog.setDescription(super.logConfig.getDescription());

stepLog.setPath(resolvedResultPath);

stepLog.setArchiveFileName(archiveFileName);

stepLog.setType(StepLog.TYPE_CUSTOM);

stepLog.setPathType(StepLog.PATH_TYPE_CHECKSTYLE_XML); // path type is file

stepLog.setFound((byte) 1);

cm.save(stepLog);

} catch (Exception e) {

throw IoUtils.createIOException(StringUtils.toString(e), e);

} finally {

IoUtils.deleteFilesHard(tempFiles);

}

}

開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:66,

示例17: getXmlDocument

​點讚 1

import org.dom4j.io.SAXReader; //導入方法依賴的package包/類

/**

* Load XML into a dom4j Document. If error, return null. No validation is performed.

*

* @param url A URL to an XML document

* @return An XML Document containing the dom4j DOM, or null if unable to process

* the file.

* @exception DocumentException If dom4j error

* @exception MalformedURLException If error in the URL

*/

public static Document getXmlDocument(URL url)

throws DocumentException, MalformedURLException {

// No validation…

SAXReader reader = new SAXReader(false);

Document document = reader.read(url);

return document;

}

開發者ID:NCAR,項目名稱:joai-project,代碼行數:17,

注:本文中的org.dom4j.io.SAXReader.read方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/150599.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • QFile和QTextStream

    QFile和QTextStreamQFile类是一个操作文件的输入/输出设备。详情请见……#include&lt;qfile.h&gt;继承了QIODevice。所有成员函数的列表。公有成员QFile()QFile(const QString &amp; name)~QFile()QStringname()constvoidsetName(const QString &amp; name)typedef…

  • 【生信技能树2020-10-31】单细胞数据挖掘学习笔记-1.1 下载、探索数据

    【生信技能树2020-10-31】单细胞数据挖掘学习笔记-1.1 下载、探索数据生信技能树-单细胞数据挖掘学习笔记2.1

    2022年10月25日
  • html空格代码_html中空格怎么表示

    html空格代码_html中空格怎么表示html中空格代码的写法一:&nbsp(不换行空格)html中空格代码的写法二:&ensp(半角空格)html中空格代码的写法三:&emsp(全角空格)html中空格代码的写法四:&thinsp(窄空格)html中空格代码的写法五:&zwnj(零宽不连字)说明:&zwnj是一个不打印字符,放在电子文本的两个字符之间,抑制本来会发生的连字,而是以这两个字符原本的字形来绘制。html中空格代码的写法六:&zwj(零宽连字)说明:&amp

  • Linux 命令学习之dpkg命令详解

    Linux 命令学习之dpkg命令详解dpkg是一个Debian的一个命令行工具,它可以用来安装、删除、构建和管理Debian的软件包。下面是它的一些命令解释:1)安装软件命令行:dpkg-i示例:dpkg-iavg71flm_r28-1_i386.deb2)安装一个目录下面所有的软件包命令行:dpkg-R示例:dpkg-R/usr/local/src3)释放软件包,但是不进行配置命令

  • 软件测试技术之: 白盒测试和黑盒测试[通俗易懂]

    软件测试技术之: 白盒测试和黑盒测试[通俗易懂]白盒测试和黑盒测试的区别和基本方法。

  • 建立排序二叉树并中序遍历

    建立排序二叉树并中序遍历分析:中序遍历也叫中根遍历,顾名思义是把根节点放在中间来遍历,其遍历顺序为左子节点–>根节点–>右子节点。方法一:#includeusingnamespacestd;structnode//二叉树结点结构{intdata;node*left;//右子树结点指针n

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号