-2
    String strFileContent="";    
    Log.e(TAG, "Error loading image file names333");
    StringBuilder contents = new StringBuilder();///

    for (int i = 0; i < x.length; i++) {
        ///strFileContent += ""+x[i]+",";
        contents.append(x[i]);///
    contents.append(System.getProperty("line.separator"));///
    }
    strFileContent=contents.toString();///

String file = "scores8";

java或android:如何从字符串数组x []每行一个元素创建一个文本文件???什么类型的文件不使用 ext 或 txt 或...???

4

2 回答 2

0

您可以在 Apache Commons IO 中使用FileUtils :

FileUtils.writeLines(new File("file.txt"), Arrays.asList(array));
于 2012-08-31T14:41:34.150 回答
0
String[] array = {...};
File file = new File("FilePath");
PrintWriter pw = new PrintWriter(file, true);
for(String s : array) pw.println(s);
pw.close();
于 2012-08-31T14:35:22.907 回答