對於Logcat打不全的思考

今天碰到一個問題,後臺給我一個json字符串,由於太長,logcat打不全,上網查了資料,好像是logcat有長度限制,需要分段打印。

後來我就想,直接新建一個txt,把這個string放進去,再用ADM導出文件就好了。

代碼

//獲取SD卡的路徑
String pathString = Environment.getExternalStorageDirectory().getPath();
File file = new File(pathString+"/"+"xxx.txt");
//判斷文件是否存在
if(!file.exists()){
//創建新文件
file.createNewFile();
}
//創建一個文件輸出流
FileOutputStream out = new FileOutputStream(file,true);//true表示在文件末尾添加
out.write(s.getBytes("UTF-8"));
out.close();

 

發佈了28 篇原創文章 · 獲贊 17 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章