ITeye博客

invoke google api demo

skyyfd · 2010-03-31 14:06 · technology · 编程语言 · Java · Google · .net · XML · Markdown

package request;

import java.io.BufferedReader; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLEncoder;

public class Main { public static void main(String[] args) throws UnsupportedEncodingException { String encoding = System.getProperty("file.encoding"); System.out.println(encoding); String encoding1 = URLEncoder.encode("林", "utf-8");

		System.out.println(encoding1);
	try {
		URL my_url = new URL(

// "http://127.0.0.1:4664/search?q=%E5%BA%84%E6%B0%B8%E5%94%A4&flags=68&num=10&s=t4VEGJVSnbZ9Mf8Ruz6SGqPcTYA&format=xml"); // "http://127.0.0.1:4664/search&s=XZAXASVZUPL4rIYhwEiuY-PCwfE?q=file&num=10&format=xml"); "http://127.0.0.1:4664/search&s=XZAXASVZUPL4rIYhwEiuY-PCwfE?q="+encoding1+"&num=10&format=xml"); InputStreamReader input = new InputStreamReader(my_url.openStream(),"UTF-8"); BufferedReader br = new BufferedReader(input);

		String strTemp = "";
		while (null != (strTemp = br.readLine())) {
			System.out.println(strTemp);
		}
	} catch (Exception ex) {
		ex.printStackTrace();
	}
}

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。