写一个包含多个数组的.txt文件。 [英] Write a .txt file with multiple arrays.

查看:95
本文介绍了写一个包含多个数组的.txt文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将输入的信息写入.txt文件?它被输入40多个数组。



我尝试过:



How would I write the inputted info to a .txt file? It is inputted into 40+ arrays.

What I have tried:

//output
            report = new PrintWriter (new FileWriter (name [i] + "_Results.txt"));
            while(name[i].compareTo("quit")!=0)
            {
            report.print(name[i]);
            report = in.readLine();
            }
            report.close();

推荐答案

为什么每次你都试图覆盖PrintWriter绕过循环?



我建议你回到你的课程笔记并重新阅读 - 你似乎完全错了想法......



如果你想在一个单独的行上使用每个名字,那么试试println而不是print。
Why are you trying to overwrite the PrintWriter each time you go around the loop?

I suggest you go back to your course notes and reread ethm - you seem to have got the wrong idea completely...

And if you want each name on a separate line, then try println instead of print.


你好,



也许这有助于你的进一步发展:



Hello,

Maybe this helps your further:

 string[] lines = {


Test1' 测试 测试 测试,测试 测试 测试 };
System.IO.File.WriteAllLines(@
C:\ Test.txt ,行);
"Test1'", "Test", "Test", "Test", Test", "Test", "Test"}; System.IO.File.WriteAllLines(@"C:\Test.txt", lines);





将C:\ Test.txt重命名为您的路径。



Rename "C:\Test.txt" to your Path.


这篇关于写一个包含多个数组的.txt文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆