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);








原文地址:https://www.cnblogs.com/wishchin/p/9200135.html