forked from bitcocom/JavaTPCProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject01_C.java
More file actions
21 lines (21 loc) · 809 Bytes
/
Project01_C.java
File metadata and controls
21 lines (21 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.io.InputStream;
import org.json.*;
public class Project01_C {
public static void main(String[] args) {
String src="info.json";
// IO->Stream(½ºÆ®¸²)
InputStream is=Project01_C.class.getResourceAsStream(src);
if(is==null) {
throw new NullPointerException("Cannot find resource file");
}
JSONTokener tokener=new JSONTokener(is);
JSONObject object=new JSONObject(tokener);
JSONArray students=object.getJSONArray("students");
for(int i=0; i<students.length();i++) {
JSONObject student=(JSONObject)students.get(i);
System.out.print(student.get("name")+"\t");
System.out.print(student.get("address")+"\t");
System.out.println(student.get("phone"));
}
}
}