写入本地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);
本文介绍了一个简单的Android应用程序函数,用于将字符串消息写入到设备的SD卡中指定路径下的文件。通过FileOutputStream实现文件写入操作,并进行了异常处理。

被折叠的 条评论
为什么被折叠?



