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;未經允許,請勿轉載。

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

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

(0)
上一篇 2022年6月22日 下午9:36
下一篇 2022年6月22日 下午9:36


相关推荐

  • GetType和typeof的区别 以及一个小实例

    GetType和typeof的区别 以及一个小实例

    2021年8月15日
    59
  • Android入门教程二之开发环境搭建[通俗易懂]

    Android入门教程二之开发环境搭建[通俗易懂]不废话,直接上车:现在主流的Android开发环境有:①Eclipse+ADT+SDK②AndroidStudio+SDK③IntelliJIDEA+SDK现在国内大部分开发人员还是使用的Eclipse,而谷歌宣布不再更新ADT后,并且官网也去掉了集成Android开发环境的Eclipse下载链接,各种现象都表示开发者最后都终将过渡到AndroidStud

    2022年5月30日
    40
  • python怎么读取csv文件-使用Python读写csv文件的三种方法

    python怎么读取csv文件-使用Python读写csv文件的三种方法行之间无空行十分重要 如果有空行或者数据集中行末有空格 读取数据时一般会出错 引发 listindexout 错误 PS 已经被这个错误坑过很多次 使用 pythonI O 写入和读取 CSV 文件使用 PythonI O 写入 csv 文件以下是将 birthweight dat 低出生体重的 dat 文件从作者源处下载下来 并且将其处理后保存到 csv 文件中的代码 imp

    2026年3月27日
    2
  • UFW防火墙简单设置

    UFW防火墙简单设置转载 https wiki ubuntu com cn UFW E9 98 B2 E7 81 AB E5 A2 99 E7 AE 80 E5 8D 95 E8 AE BE E7 BD AEUFW 防火墙简单设置 ufw 是一个主机端的 iptables 类防火墙配置工具 比较容易上手 一般桌面应用使用 ufw 已经可以满足要求了 目录 nbsp 隐藏 nbsp 1 nbsp 安装方法 2 nbsp 使用方法 3 nbsp 推荐设置 4 nbsp 详细使用说明安装方法

    2026年3月18日
    3
  • Java文件上传详解

    Java文件上传详解Java文件上传详解文件上传和下载准备工作使用类介绍代码编写文件上传和下载在Web应用中,文件上传和下载功能是非常常用的功能,这篇博客就来讲一下JavaWeb中的文件上传和下载功能的实现。准备工作对于文件上传,浏览器在上传的过程中是将文件以流的形式提交到服务器端的。一般选择采用apache的开源工具common-fileupload这个文件上传组件。common-fileupload是依赖于common-io这个包的,所以还需要下载这个包。首先下载最新的jar包https://mvnr

    2022年5月14日
    43
  • 大神的算法学习之路

    大神的算法学习之路我的算法学习之路关于严格来说,本文题目应该是我的数据结构和算法学习之路,但这个写法实在太绕口——况且CS中的算法往往暗指数据结构和算法(例如算法导论指的实际上是数据结构和算法导论),所以我认为本文题目是合理的。原文链接:http://zh.lucida.me/blog/on-learning-algorithms/原文作者:Lucida这篇文章讲了什么?我这些年学习数据结构…

    2022年6月19日
    36

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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