android-code-saveLog
来源:互联网 发布:js 数组转对象 编辑:程序博客网 时间:2024/05/22 10:50
来自vlc0.9.9版本。
一个工具类。第一个用来将logcat保存到文件,第二个用来获得logcat字符串。
public class Logcat { public final static String TAG = "VLC/Util/Logcat"; /** * Writes the current app logcat to a file. * * @param filename The filename to save it as * @throws IOException */ public static void writeLogcat(String filename) throws IOException { String[] args = { "logcat", "-v", "time", "-d" }; Process process = Runtime.getRuntime().exec(args); InputStreamReader input = new InputStreamReader(process.getInputStream()); FileOutputStream fileStream; try { fileStream = new FileOutputStream(filename); } catch( FileNotFoundException e) { return; } OutputStreamWriter output = new OutputStreamWriter(fileStream); BufferedReader br = new BufferedReader(input); BufferedWriter bw = new BufferedWriter(output); try { String line; while ((line = br.readLine()) != null) { bw.write(line); bw.newLine(); } }catch(Exception e) {} finally { bw.close(); output.close(); br.close(); input.close(); } } /** * Get the last 500 lines of the application logcat. * * @return the log string. * @throws IOException */ public static String getLogcat() throws IOException { String[] args = { "logcat", "-v", "time", "-d", "-t", "500" }; Process process = Runtime.getRuntime().exec(args); InputStreamReader input = new InputStreamReader( process.getInputStream()); BufferedReader br = new BufferedReader(input); StringBuilder log = new StringBuilder(); String line; while ((line = br.readLine()) != null) log.append(line + "\n"); br.close(); input.close(); return log.toString(); }}
0 0
- android-code-saveLog
- savelog.java
- Android code
- Android Migrate Android Code
- Android Migrate Android Code
- 初学Android简单code
- android source code list
- Android source code debug
- Building the android code
- Android download source code
- Get Android Source Code
- Get Android Source Code
- Android Native Code调试
- Debug Android native code
- Android Code Style Rules
- Android Source code
- android 应用开发code
- Android source code
- (亲测兼容360、IE、谷歌、火狐等浏览器)鼠标悬停显示页面被截取字段的全部内容
- hdu 5017 ellipsoid 退火大法
- android中sd卡常用状态
- swift,函数
- dom4j解析xml
- android-code-saveLog
- QML类型说明-Image
- 关于dfs和dp的思考
- spring JdbcTemplate
- Andriod Parcelable 读写 boolean(布尔值)的步骤
- linux 获取系统 页大小
- iOS设备的UDID是什么?苹果为什么拒绝获取iOS设备UDID的应用?如何替代UDID?
- fdisk命令分析
- Process学习