protected void send() {
try {
is = getAssets().open("Data.json");
int len;
byte[] arr = new byte[1024];
StringBuffer sb = new StringBuffer();
while ((len = is.read(arr)) != -1) {
sb.append(new String(arr, 0, len, "UTF-8"));
}
String string = sb.toString();
Log.i("data", string + "kkkk");
Gson gson = new Gson();
Type type = new TypeToken<ArrayList<aa>>() {
}.getType();
List<aa> list = gson.fromJson(string, type);
for (aa aa : list) {
System.out.println(aa.body);
System.out.println(aa.id);
System.out.println(aa.number);
}
} catch (Exception e) {
e.printStackTrace();
}
}
在Bean中注意
package com.example.bean;
import java.util.List;
public class Bean {
public List<aa> list;
public class aa {
public String body;
public String id;
public String number;
}
}