-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadwiki.java
More file actions
26 lines (21 loc) · 792 Bytes
/
loadwiki.java
File metadata and controls
26 lines (21 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class main {
static String wikiT = "Apple_Inc.";
static String strURL = "http://en.wikipedia.org/w/api.php?format=json&action=query&titles="+wikiT+"&prop=extracts&rvprop=content";
public static void main(String[] args) throws IOException {
URL url = new URL(strURL);
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
for (String line; (line = reader.readLine()) != null;) {
System.out.println(line);
}
} finally {
if (reader != null) try { reader.close(); } catch (IOException ignore) {}
}
}
}