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

Posted spps

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了把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("\r\n");
bw.flush();
}
bw.close();

} catch (Exception e) {

}

以上是关于把ArrayList集合中的字符串内容写到文本文件中的主要内容,如果未能解决你的问题,请参考以下文章