把ArrayList集合中的字符串内容写到文本文件中

list列表数据导出到指定路径文本文档中
public  String getSDCardPath() {
String sdCard = Environment.getExternalStorageDirectory().getAbsolutePath();
sdCard = sdCard + File.separator;
return sdCard;
}

String mExportPath=getSDCardPath() + "TianChao/"+"Export/";
File file =new File(mExportPath);
if(!file.exists()){
file.mkdirs();
}
String filename="nfc.txt";
filename=filename.replaceAll("nfc",mTagNameNew);
File f=new File(mExportPath+filename);
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(f));
for(String s: mNFCs){
bw.write(s);
bw.write(" ");
bw.flush();
}
bw.close();

} catch (Exception e) {

}

原文地址:https://www.cnblogs.com/spps/p/8761329.html