创建行数不受限制的 java 文件

我正在使用 java 写入文件,并且正在写入超过 47678 行。文件中的最大行数是 47678。我想知道是否可以扩展行数或者我应该做什么。我正在使用 File 创建文件,并使用 FileWriter 进行写入



繁华开满天机
浏览 49回答 1
1回答

幕布斯7119047

我没有发现任何问题,例如以下程序将在文件中写入 65535 行:import java.io.*;class TestClass {&nbsp; &nbsp; public static void main(String args[]) throws IOException {&nbsp; &nbsp; &nbsp; &nbsp; BufferedWriter writer = new BufferedWriter(new FileWriter("test.txt"));&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0;i<65535;i++)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.write("Happy Diwali!\n");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; writer.close();&nbsp;&nbsp; &nbsp; }}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java