-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetEricStupidJson.java
40 lines (37 loc) · 1.18 KB
/
GetEricStupidJson.java
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
* Write a description of class GetEricStupidJson here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class GetEricStupidJson
{
// instance variables - replace the example below with your own
public void main(){
//JSONArray j = JSONArray.fromObject("[1,2]");
// System.out.println(j.toString());
/**
String url = "http://192.168.1.106:8080/test/test.json";
InputStream is = new URL(url).openStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is,"utf-8")); //�?��?中文亂碼�?題
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
JSONObject json = JSONObject.fromObject(sb.toString());
System.out.println(json.get("hello"));
} finally {
is.close();
}
**/
}
}