---
title: "invoke google api demo"
author: "skyyfd"
date: "2010-03-31T14:06:16Z"
tags: [".net", "Google", "Java", "XML"]
categories: ["编程语言"]
slug: "invoke-google-api-demo"
draft: false
lastmod: "2010-03-31T14:06:16Z"
id: 629134
url: "https://ddeererer.iteye.com/blog/629134"
---

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();
		}
	}
}