Rss & SiteMap

课外天地 李树青 http://www.njcie.com

李树青 论坛 南京 财经 课外天地
共1 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:利用HTTP请求方式获取eXist查询结果的简单程序

1楼
admin 发表于:2009/5/27 22:46:25

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

public class Exec {
    public static void main(String args[]) {
        FileOutputStream fos;
        URL url;
        URLConnection urlConnection;
        InputStream is;
        int i;

        try {
            fos = new FileOutputStream("results.xml");
            url = new URL(
                    "http://localhost:8080/exist/servlet/db/?_query=for $p in //stu where contains($p,'exam') return $p");
            urlConnection = url.openConnection();
            is = urlConnection.getInputStream();

            i = is.read();
            while (i > 0) {
                fos.write(i);
                i = is.read();
            }
            fos.close();
            is.close();
        } catch (IOException e) {
        }
    }
}

[此贴子已经被作者于2010-12-14 09:41:55编辑过]
共1 条记录, 每页显示 10 条, 页签: [1]

Copyright ©2002 - 2016 课外天地.Net
Powered By Dvbbs Version 8.3.0
Processed in .04688 s, 2 queries.