Android测试写入文本Log
写入本地SD卡:
@SuppressLint("SdCardPath") public void writeFileSdcard(String fileName, String message) { try { FileOutputStream fout = new FileOutputStream(fileName); byte[] bytes = message.getBytes(); fout.write(bytes); fout.close(); } catch (Exception e) { e.printStackTrace(); } }
测试函数:
String message=""; String filename ="/sdcard/DevCv/Log/"; filename += "Log_projectPoints" + ".txt"; writeFileSdcard(filename, message);