This commit is contained in:
2021-02-19 18:27:46 +08:00
parent 7a4ef531d1
commit 0124112260
10 changed files with 449 additions and 31 deletions

View File

@@ -0,0 +1,38 @@
package utils;
import android.content.Context;
import android.content.res.AssetManager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* <读取Json文件的工具类>
*
* @author: 小嵩
* @date: 2017/3/16 16:22
*/
public class GetJsonDataUtil {
public String getJson(Context context,String fileName) {
StringBuilder stringBuilder = new StringBuilder();
try {
AssetManager assetManager = context.getAssets();
BufferedReader bf = new BufferedReader(new InputStreamReader(
assetManager.open(fileName)));
String line;
while ((line = bf.readLine()) != null) {
stringBuilder.append(line);
}
} catch (IOException e) {
e.printStackTrace();
}
return stringBuilder.toString();
}
}