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








posted @ 2015-08-03 20:51  wishchin  阅读(152)  评论(0编辑  收藏  举报