GBaseExample.java

Allikas: Lambda
/*
 * Google base reading demo
 */


import java.net.*;
import java.io.*;

 
public class GBaseExample {
  
  private static String SNIPPETS_FEED = "http://base.google.com/base/feeds/snippets";
  private static String FREEQUERY = "book";
  private static String FIXQUERY = "[product type : books][author : Shakespeare]";  
  private static String DEVELOPER_KEY = "";
  

  public static void main(String[] args) throws IOException {
    
    URL url;
    BufferedReader in;
    String inputLine;
    
    url = new URL(SNIPPETS_FEED +  "?bq=" + URLEncoder.encode(FIXQUERY, "UTF-8"));
        //"&q=" + URLEncoder.encode(FREEQUERY, "UTF-8") + 
        //"&alt=json-in-script" + 
        //"&key=" + DEVELOPER_KEY); 
    
    in = new BufferedReader(new InputStreamReader(url.openStream()));	
    
    while ((inputLine = in.readLine()) != null)
	   System.out.println(inputLine);

    in.close();
  }
}