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");
Ïà¹ØÎĵµ£º
public boolean copy(String from, String to) {
boolean temp=true;
FileInputStream stream;
try {
stream = new FileInputStream(new File(from));
FileOutputStream bos = new FileOutputStream(to);
int bytesRea ......
JAVAÖеĴ«µÝ¶¼ÊÇÖµ´«µÝÂð£¿ÓÐûÓÐÒýÓô«µÝÄØ£¿
ÔڻشðÕâÁ½¸öÎÊÌâǰ£¬ÈÃÎÒÃÇÊ×ÏÈÀ´¿´Ò»¶Î´úÂ룺
Java´úÂë
public class ParamTest {
// ³õʼֵΪ0
protected int num = 0;
// Ϊ·½·¨²ÎÊýÖØÐ¸³Öµ
public void change(int i) {
i = 5;
}
// Ϊ·½·¨²ÎÊýÖØÐ¸³Öµ
public void change(ParamTest t) {
P ......
JavaÀï±ß½âÎöxmlÒ»°ãÓÐÈýÖÖ³£Óõļ¼Êõ£º
1¡¢ Document Object Model (DOM)£¬W3CÀï±ßÒ»ÖÖ³ÉÊìµÄ±ê×¼¡£Ä¿Ç°¹ã·ºÊ¹ÓõĽâÎö¹¤¾ß£ºJDOM DOM4J
2¡¢ Simple API for XML (SAX)£¬µÚÒ»ÖÖ±»¹ã·º½ÓÊܵÄXMLµÄAPI£¬³ÉΪÊÂʵÉϵıê×¼¡£
3¡¢ Streaming API for XML (StAX)£¬ÔÚJSR-173ÖÐÌáµ½µÄÒ»ÖÖºÜÓÐǰ;µÄÐÂÐͽâÎöÄ ......
1.¼ÆËãijһÔ·ݵÄ×î´óÌìÊý
Calendar time=Calendar.getInstance();
time.clear();
time.set(Calendar.YEAR,year); //year Ϊ int
time.set(Calendar.MONTH,i-1);//×¢Òâ,Calendar¶ÔÏóĬÈÏÒ»ÔÂΪ0
int day=time.getActualMaximum(Calendar.DAY_OF_MONTH) ......
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 {
......