从XML中读取图片并生成
2011-04-15 16:33
218 查看
package com.neusoft.zzn;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import sun.misc.BASE64Decoder;
/**
* 从XML文件中读取图片,并生成图片
*
* @author 张志南 zhangzhinan@neusoft.com
*
*/
public class XmlToImg {
public static void main(String[] args) {
File f = new File("C://lexus.xml");
SAXReader reader = new SAXReader();
try {
Document doc = reader.read(f);
Element root = doc.getRootElement();
Element image = (Element) root.selectSingleNode("imageData");
String s_data = image.getText();
BASE64Decoder decoder = new BASE64Decoder();
byte[] data = decoder.decodeBuffer(s_data);
FileOutputStream fos = new FileOutputStream("C://test_lexus.jpg");
fos.write(data);
fos.flush();
fos.close();
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import sun.misc.BASE64Decoder;
/**
* 从XML文件中读取图片,并生成图片
*
* @author 张志南 zhangzhinan@neusoft.com
*
*/
public class XmlToImg {
public static void main(String[] args) {
File f = new File("C://lexus.xml");
SAXReader reader = new SAXReader();
try {
Document doc = reader.read(f);
Element root = doc.getRootElement();
Element image = (Element) root.selectSingleNode("imageData");
String s_data = image.getText();
BASE64Decoder decoder = new BASE64Decoder();
byte[] data = decoder.decodeBuffer(s_data);
FileOutputStream fos = new FileOutputStream("C://test_lexus.jpg");
fos.write(data);
fos.flush();
fos.close();
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
相关文章推荐
- jsfl读取xml,图片,并生成swf
- Android开发之--读取文件夹下图片生成略缩图并点击显示大图
- Asp.net(C#)读取数据库并生成JS文件制作首页图片切换效果(附demo源码下载)
- OpenCV_读取文件夹下的图片生成视频文件
- (爱加密系列教程十)apk反编译生成程序的源代码和图片、XML配置、语言资源等文件
- 读取 生成 格式化 XML 文件
- xml保存图片和读取图片
- Java 如何读取sqlserver生成的xml
- 读取生成的xml
- DOM模型的XML文件生成读取
- 用JDOM+Base64编码存储和读取图片进XML
- 简单的从数据库中读取数据自动生成XML
- ASP读取数据库内容,生成XML
- 使用Pull解析器生成XML文件和读取xml文件
- java 读取图片文件再生成新图片
- 反编译apk生成程序的源代码和图片、XML配置、语言资源等文件
- xml图片的生成
- 利用dom4j 读取javabean生成XML和读取XML得到javabean对象(集合)
- JXTree对象,读取外部xml文件数据,生成树的函数
- (安全系列二)apk反编译生成程序的源代码和图片、XML配置、语言资源等文件