- 浏览: 73559 次
- 性别:
- 来自: 天津
文章分类
最新评论
-
lijx127:
例1的输出结果应该是:this is toString
JAVA中tostring方法的作用 -
chengdaohuang:
不错 我正好在用这个方法的时候出了问题,苦于找不到解决思路 ...
Java中toArray的用法探究 -
javer:
...
Java中toArray的用法探究
import java.io.FileOutputStream;
import java.io.IOException;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.output.XMLOutputter;
public class Java2XML {
public void BuildXMLDoc() throws IOException, JDOMException {
// 创建根节点 list;
Element root = new Element("list");
// 根节点添加到文档中;
Document Doc = new Document(root);
// 此处 for 循环可替换成 遍历 数据库表的结果集操作;
for (int i = 0; i < 5; i++) {
// 创建节点 user;
Element elements = new Element("user");
// 给 user 节点添加属性 id;
elements.setAttribute("id", "" + i);
// 给 user 节点添加子节点并赋值;
// new Element("name")中的 "name" 替换成表中相应字段,setText("xuehui")中 "xuehui 替换成表中记录值;
elements.addContent(new Element("name").setText("xuehui"));
elements.addContent(new Element("age").setText("28"));
elements.addContent(new Element("sex").setText("Male"));
// 给父节点list添加user子节点;
root.addContent(elements);
}
XMLOutputter XMLOut = new XMLOutputter();
// 输出 user.xml 文件;
XMLOut.output(Doc, new FileOutputStream("user.xml"));
}
public static void main(String[] args) {
try {
Java2XML j2x = new Java2XML();
System.out.println("生成 mxl 文件...");
j2x.BuildXMLDoc();
} catch (Exception e) {
e.printStackTrace();
}
}
}
import java.io.IOException;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.output.XMLOutputter;
public class Java2XML {
public void BuildXMLDoc() throws IOException, JDOMException {
// 创建根节点 list;
Element root = new Element("list");
// 根节点添加到文档中;
Document Doc = new Document(root);
// 此处 for 循环可替换成 遍历 数据库表的结果集操作;
for (int i = 0; i < 5; i++) {
// 创建节点 user;
Element elements = new Element("user");
// 给 user 节点添加属性 id;
elements.setAttribute("id", "" + i);
// 给 user 节点添加子节点并赋值;
// new Element("name")中的 "name" 替换成表中相应字段,setText("xuehui")中 "xuehui 替换成表中记录值;
elements.addContent(new Element("name").setText("xuehui"));
elements.addContent(new Element("age").setText("28"));
elements.addContent(new Element("sex").setText("Male"));
// 给父节点list添加user子节点;
root.addContent(elements);
}
XMLOutputter XMLOut = new XMLOutputter();
// 输出 user.xml 文件;
XMLOut.output(Doc, new FileOutputStream("user.xml"));
}
public static void main(String[] args) {
try {
Java2XML j2x = new Java2XML();
System.out.println("生成 mxl 文件...");
j2x.BuildXMLDoc();
} catch (Exception e) {
e.printStackTrace();
}
}
}
发表评论
-
Java常用正则表达式
2010-09-26 21:46 700Java常用正则表达式 正则几个基本概念: 1.贪婪:+, ... -
Maven入门--概念与实例
2010-09-23 13:19 6181 关键名词 Project:任何您想build的事 ... -
Java Reflection (JAVA反射)
2010-09-23 13:11 583Java Reflection (JAVA反射) ... -
Java PreparedStatement
2010-09-23 13:05 2425该 PreparedStatement接口继承Statemen ... -
Java Statement
2010-09-23 13:03 914java Statement详细用法 创建 Statement ... -
Java面试题
2010-09-23 11:55 1330第一章 JAVA基础知识 §1.1 Java概述 1.完成在 ... -
从指定网址下载网页
2010-09-23 10:10 807import java.net.URL; import jav ... -
Java中equals和==的区别
2010-09-15 23:18 508值类型是存储在内存中的堆栈(以后简称栈),而引用类型的变量在栈 ... -
JAVA 转义字符
2010-09-08 23:07 1505转义序列 含义 \n 回车(\u000a) \t 水平制表 ... -
JAVA的位移运算巧方法
2010-09-06 22:23 615左移操作: x << n x可以是byte, ... -
对Java中四种XML解析技术之不完全测试
2010-09-05 22:32 581平时工作中,难免会遇到把XML作为数据存储格式。面对目前种类繁 ... -
Java this变量总结
2010-09-05 22:22 535this为一系统资源,只允许用户读而不允许写,它存放当前对象的 ... -
Timestamp基础知识及时间大小比较
2010-09-05 18:28 1383主要写一些与数据库连接时的日期处理,pstmt.setDate ... -
java读取properties文件
2010-09-05 18:23 653一. .properties 文件的形 ... -
Java中ArrayList和LinkedList区别
2010-09-05 18:19 501一般大家都知道arraylist和linkedlist的大致区 ... -
Java中hashcode()方法和equals方法
2010-09-05 18:17 532hashcode这个方法是用来鉴定2个对象是否相等的。 ... -
Java中equals和==的区别
2010-09-05 18:13 580值类型是存储在内存中的堆栈(以后简称栈),而引用类型的变量在栈 ... -
Java反射测验代码
2010-09-05 18:10 495Java代码 package reflect; imp ... -
Java异常处理的一般性原则
2010-09-05 18:06 7051)首先,不要丢弃异常 ... -
Java 栈与堆都
2010-09-05 18:02 510栈与堆都是Java用来在Ram ...
相关推荐
Java and XML, 3rd Edition, shows you how ... You'll learn how to create, read, and modify RSS feeds for syndicated content and use XML to power the next generation of websites with Ajax and Adobe Flash.
Create, validate, parse, and transform XML documents Apply Java’s SAX, DOM, StAX, XPath, and XSLT APIs Master the JSON format for serializing and transmitting data Code against third-party APIs such ...
只需要导入aspose-words-14.9.0-jdk16.jar 这个jar包,不需要什么license.xml,直接去水印,不需要什么反编译啥的,直接就用了,不好用找我,绝对不骗人,网上好多都是去不了水印,而且还有些根本跑不了,还有就是...
将create_bindingconfigs.sh Shell脚本(-> mescedia / xml-java-unedifact / src / main / resources / create_bindingconfigs.sh)放在smooks / unedifact源文件夹的根目录中并运行它。 这将在子文件夹...
eclipse启动时弹出Failed to create the Java Virtual Machine 一、现象 今天装eclipse的时候出现Failed to create the Java Virtual Machine 的错误。 错误图片如下: 二、出错原因 把错误提示翻译一下,就是...
This release contains Java API for XML Processing (JAXP) 1.4.5, supports Java Architecture for XML Binding (JAXB) 2.2.3, and supports Java API for XML Web Services (JAX-WS) 2.2.4. ...
it to create applications for any computing environment and Android apps that run on cell phones and other mobile devices. By the time you have finished the book, you’ll have well-rounded knowledge ...
带详细解决方案说明文档,提供三种解决方式,另外包含stax2-api.jar,stax2-api-source.jar,woodstox-core-asl-4.4.1.jar,stax-ex.jar,wstx-asl-3.2.9.jar等jar文件,亲测有效。
<creator id="new" class="uk.ltd.getahead.dwr.create.NewCreator"/>DWR已经将这配置到了内置的dwr.xml文件中,并不需要进行额外的配置. Creator通过调用类的默认的构造方法创建实例.应用new creator有以下几个优点:...
By the end of the book, you’ll be fully prepared to take advantage of Java's ease of development, and able to create powerful, sophisticated Java applications. What youll learn How to use and ...
* This book focuses on the open source Jabber XML-based IM protocols (www.jabber.org) to create Java IM software. These open protocols allowS your IM Software to seamlessly communicate with the large...
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLEventFactory; at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.(PackagePropertiesMarshaller...
the sound conceptual basis that developers need to create advanced applications. The book includes careful explanations of sometimes perplexing programming techniques along with enough background to ...
By the end of the book, you’ll be fully prepared to take advantage of Java's ease of development, and able to create powerful, sophisticated Java applications. What youll learn How to use and ...
从 Android attrs XML 生成 Java 枚举类介绍(和警告) 这是一个黑客。 而已。 我敢肯定,拥有比我更多 Gradle 技能的人可能可以将它变成一个合适的插件,但是如果你需要一些快速而肮脏的东西,试试这个……但如果它...
2、配置java环境,使用jdk8,配置环境变量,下载IntelliJ IDEA 2019.2.4,该工具为java代码编译器 3、下载Maven,配置至环境变量(百度搜索很多),将构建器为Maven,类库配置成阿里库(方法:百度搜索很多很多) 4...
此架包 flyDB V1.2 beta 为创建简单数据表的架包 ...创建数据库的方法是CreateTable工具类调用静态方法create()即可 创建表的方法是CreateTable工具类调用静态方法start()即可 更多新功能正在修正中...
In the book, you'll learn the technologies and techniques needed to create your own Web services for use in JSP applications. Written by programmers for programmers, the book will help you ...
// create and publish an endpoint Hello hello = new Hello(); Endpoint endpoint = Endpoint.publish("http://localhost:8080/hello", hello); } } Java代码 package Hello; import javax.jws....