- URL url = new URL("<a href="http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=CodeSnippet">http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=CodeSnippet");
- URLConnection connection = url.openConnection();
- connection.addRequestProperty("Referer", "<a href="http://www.CodeSnippet.Cn/">http://www.CodeSnippet.Cn/");
- String line;
- StringBuilder builder = new StringBuilder();
- BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
- while((line = reader.readLine()) != null) {
- builder.append(line);
- }
- JSONObject json = new JSONObject(builder.toString());
- // now have some fun with the results...
- //该片段来自于http://www.codesnippet.cn/detail/210120131778.html
来源: http://www.codesnippet.cn/detail/210120131778.html