LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 656|回复: 6

求助!个位 大哥帮 帮忙!

[复制链接]
发表于 2005-2-21 19:36:05 | 显示全部楼层 |阅读模式
有谁可以给我 看一下 ,往浏览器的 收藏夹里添加页面,小弟写 了 一个,但是一 重启就没有了 ,郁闷 !
我 的 真想知道这个代码该怎么写,我是用 JAVA写 的
在线等!急!!
发表于 2005-2-21 20:23:02 | 显示全部楼层
发一下代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-2-23 19:43:49 | 显示全部楼层
import org.jdom.input.*;
import java.io.*;
import org.jdom.output.*;
import org.jdom.*;
import java.util.List;

public class XmlOperation {
    //public static void main(String[] args) throws Exception {
    //    XmlOperation.PageWrite();
      //  XmlOperation.Read();
       // XmlOperation.DirCreate();
    //}
        static Document doc =null;
        static Element collection =null;
    public static void PageWrite() throws Exception {
        //boolean exists = fileExists.exists();
        //if(!exists) {
                if(doc==null&&collection==null){collection = new Element("Collection");
                doc=new Document(collection);
                }
                //for(int i=0;;i++) {
                String tree = IEInit.urlField.getText(  );
                Element page = new Element("age");
                collection.addContent(page);
                page.addContent(tree);
        //      FileWriter fw = new FileWriter(fileExists);

        //      out.output(doc,fw);
        //      fw.close();//q}
        //}else {

    }


    public static void XMLWriter() throws Exception{
        File fileExists = new File("Collection.xml");
        FileWriter fw = new FileWriter(fileExists);
                XMLOutputter out = new XMLOutputter();
                Format format = Format.getCompactFormat();
                XMLOutputter out = new XMLOutputter();
                Format format = Format.getCompactFormat();
                format.setEncoding("GB2312");
                format.setIndent(" ");
                out.setFormat(format);
                out.output(doc,fw);
                fw.close();
    }

    public static void Read() throws Exception {
        SAXBuilder sax = new SAXBuilder();
        Document doc = sax.build(new File("Collection.xml"));
        Element collection = doc.getRootElement();
        List list = collection.getChildren("age");
        for(int i=0;i<list.size();i++) {

        }
    }

    public static void DirCreate() throws Exception {

    }
}
大概是 这样
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-2-23 19:44:57 | 显示全部楼层
下面我也 写不下去了,无从下手!
回复 支持 反对

使用道具 举报

发表于 2005-2-24 09:14:57 | 显示全部楼层

re

javascript行不??
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-2-25 18:44:42 | 显示全部楼层
。。。。javascript,我 大概知道一点,老师叫我们用JAVA
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-2-28 16:01:48 | 显示全部楼层
现在大概思路就是吧 页面保存在一 个 XML里面,从XML里面读,我 搞定了 ,就是 往XML里面写,有问题,每次一重启就没有了,郁闷!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表