1、从asset路径下读取对应文件转String输出
public static String getJson(Context mContext, String fileName) {// TODO Auto-generated method stubStringBuilder 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 blocke.printStackTrace();sb.delete(0, sb.length());}return sb.toString().trim();}
调用代码如下:
getJson(Tag, "xxx.json")