⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queryexample1.java

📁 google的gdata api包
💻 JAVA
字号:
/* Copyright (c) 2006 Google Inc.                                                                                                                                                                                 *                                                                                                                                                                                                                * Licensed under the Apache License, Version 2.0 (the "License");                                                                                                                                                * you may not use this file except in compliance with the License.                                                                                                                                               * You may obtain a copy of the License at                                                                                                                                                                        *                                                                                                                                                                                                                *     http://www.apache.org/licenses/LICENSE-2.0                                                                                                                                                                 *                                                                                                                                                                                                                * Unless required by applicable law or agreed to in writing, software                                                                                                                                            * distributed under the License is distributed on an "AS IS" BASIS,                                                                                                                                              * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.                                                                                                                                       * See the License for the specific language governing permissions and                                                                                                                                            * limitations under the License.                                                                                                                                                                                 */package com.google.api.gbase.examples.basic;import java.io.IOException;import java.io.InputStream;import java.net.HttpURLConnection;import java.net.URL;import java.net.URLEncoder;/** * Dumps to the console the response of a Google Base data API query.  */public class QueryExample1 {  /**   * Url of the Google Base data API snippet feed.   */  private static final String SNIPPETS_FEED = "http://base.google.com/base/feeds/snippets";  /**   * The query that is sent over to the Google Base data API server.   */  private static final String QUERY = "cars [item type : products]";  /**   * Insert here the developer key obtained for an "installed application" at   * http://code.google.com/apis/base/signup.html   */  private static final String DEVELOPER_KEY = "";  /**   * Connect to <code>SNIPPETS_FEED</code> and display the response.    * @throws IOException if an error occured while connecting or reading from    *         the feed   */  public void displayItems() throws IOException {    URL url = new URL(SNIPPETS_FEED + "?bq=" +         URLEncoder.encode(QUERY, "UTF-8") + "&key=" + DEVELOPER_KEY);     HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection();    InputStream inputStream = httpConnection.getInputStream();        int ch;    while ((ch=inputStream.read()) > 0) {      System.out.print((char)ch);    }  }  /**   * The main method simply creates a <code>QueryExample2</code> instance and   * calls <code>displayItems</code>.    */  public static void main(String[] args) throws IOException {    new QueryExample1().displayItems();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -