Java对象XML序列化框架-Simple2.0
Java对象XML序列化框架-Simple2.0
Simple是一个XML序列化框架,一个Java
版本宽容的序列化框架,能够快速在Java
平台上开发XML。支持通过annotations完全配置化的XML结构;提供版本管理框架允许向前和向后兼容序列化;更好的性能,使用轻量级StAX提升XML反序列化
进程,比XStream和JAXB更快;通过namespace annotations提供完全的命名空间支持;包括XML模板系统
目前最新版本为 2.0.1. 官网地址:http://simple.sourceforge.net/home.php
注:不过笔者认为,如果你使用JavaSE 6.0,则建议使用其自带的JAXB
(Java Architecture for XML Binding).其使用非常简单,支持通过annotations完全配置化的XML结构。而且其也是Java中的一个规范实现, JAX-RS规范
就使用JAXB来实现对象的序列化功能。
下面是一个简单示例:
先定义一个Example对象, 我们只需要简单的加上Annoation后,就可以进行对象与XML之间的转换。
@Root
public
class
Example {
@Element
private
String text;
@Attribute
private
int
index;
public
Example() {
super
();
}
public
Example(String text,
int
index) {
this
.text
=
text;
this
.index
=
index;
}
public
String getMessage() {
return
text;
}
public
int
getId() {
return
index;
}
}
进行XML序列化操作:
Serializer serializer
=
new
Persister();
Example example
=
new
Example(
"
Example message
"
,
123
);
File result
=
new
File(
"
example.xml
"
);
serializer.write(example,&
相关文档:
先看一段代码
public class Hello{
public static void main(String[] args){
int i = 5 , j = 2;
System.out.println(i+j);
......
<!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:宋体;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@SimSun&qu ......
package fileIo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
public&nb ......
最佳答案
1. 编写范例文档
public class TestNative
{
private native static int Max(int a,int b);
public static void main(String[] args)
{
System.out.println(Max(4,5));
}
static
{
System.loadLibrary("VCdll");
}
}
其中
LoadLibrary中的DLL文件名称可以 ......