java 生成xml文件
	
    
    
	import java.awt.Image;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
public class createXml
{
	public static boolean writeXml(String path,String dir,String wpath,String wname)
	{
		File[] files = ReaderListFiles(path);
		boolean flag = false;
		if(files!=null)
		{
			StringBuffer xml = ReaderFilesContent(files,dir);
			if(xml!=null)
				flag = writeXmlFile(wname,wpath,xml);
		}
		
		return flag;
	}
	
	private static File[] ReaderListFiles(String path)
	{
		File file = new File(path);
		if(file.exists()&&file.isDirectory())
			return file.listFiles();
		else if(file.exists()&&file.isFile())
		{
			File[] files = new File[1];
			files[0] = file;
			return files;
		}
		else
			return null;
	}
	
	private static StringBuffer ReaderFilesContent(File[] files,String dir)
	{
		StringBuffer txml = new StringBuffer(); 
		for(int i=0;i<files.length;i++)
		{
			String filename = files[i].getName();
			String temp = filename.substring(filename.lastIndexOf(".")+1);
			if(temp!=null&&(temp.equals("gif")||temp.equals("jpg")||temp.equals("bmp")||temp.equals("jpeg")||temp.equals("png")))
				txml.append(getImgDesc(filename,temp,dir,files[i]));
		}
		if(txml.length()>0)
		{
			StringBuffer xml = new StringBuffer("<?xml version='1.0' encoding='GBK'?>\r\n");
			xml.append("<firstnode>\r\n");
			xml.append(txml);
			xml.append("</firstnode>");
			return xml;
		}
		else
			return null;
	}
	
	private static StringBuffer getImgDesc(String filename,String type,String dir,File file)
	{
		Image imgSrc;
		StringBuffer xml = new StringBuffer();
		try {
			imgSrc = ImageIO.read(file);
			int width = imgSrc.getWidth(null);
			int height = imgSrc.getHeight(null);
			xml.append("\t<secondnode id=\"").append(filename).append("\">\r\n");
			xml.append("\t\t<name>").append(filename).append("</name>\r\n");
	
    
     
	
	
    
    
	相关文档:
        
    
    1、页面编码与后台类编码不一致。
2、后台类与数据库交互保持数据时产生乱码。解决方法:可以在驱动的url参数中指定。
3、读文件/流时产生乱码。解决方法:建议使用FileReader和FileWriter的父类:InputStreamReader/OutputStreamWriter,它们在构造函数中可以指定编码类型:InputStreamReader(InputStream in, Charset c ......
	
    
        
    
    1.基本概念的理解
  绝对路径:绝对路径就是你的主页上的文件或目录在硬盘上真正的路径,(URL和物理路径)例如:
C:\xyz\test.txt 代表了test.txt文件的绝对路径。http://www.sun.com/index.htm也代表了一个
URL绝对路径。
  相对路径:相对与某个基准目录的路径。包含Web的相对路径(HTML中的相对目录),例如:在
 ......
	
    
        
    
    class TestTryFinallyC {
	 public static void main(String[] args)  {
	        System.out.println(testt());
	    }
	    
	    public static int testt() {
	        int x = 99;
	    	try {
	        	return x;
	        }finally {
	            x = 8;
	        }
	    }
}
 
某年某月的某一天, ......
	
    
        
    
    import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Iterator;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class ReadSetting {
	 ......