public static String getJson(Context mContext, String fileName) {
// TODO Auto-generated method stub
StringBuilder sb = new StringBuilder();
AssetManager am = mContext.getAssets();
try {
BufferedReader br = new BufferedReader(new InputStreamReader(
am.open(fileName)));
String next = "";
while (null != (next = br.readLine())) {
sb.append(next);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sb.delete(0, sb.length());
}
return sb.toString().trim();
}
调用代码如下:
getJson(Tag, "xxx.json")