【发布时间】:2013-12-12 12:02:51
【问题描述】:
我想逐行读取java中的文件。例如,我有一个文件为 new.txt
新的.txt
Log points:
1. We develop a project about Preventive Maintenance Checklist for Employees on PC/Tablet using Java.
2. We here have check boxes for checking the list of works for quarterly, half yearly and annually.
3. This tool is created to check the lists.
4. This tool is created to make no human errors
5. This tool is created using eclipse development tool.
6. Eclipse is an IDE – Integrated development environment.
7. Eclipse is a java development tool with many plug-ins and supports.
8. We use WAMP server as database server which hosts the database connectivity.
9. The database is created using the Mysql. Mysql is free source tool for creating database.
10. The project has a user interface which is created using JSP –Java server pages.
11. Jsp is used for user interface designing and it is compiled in java compiler.
12. Servlets are server side scripting. Which accepts client side requests from the jsp and it connects with the business logic and gives the response.
13. Our application runs in Apache tom cat server. It is free server developed and released by apache software foundation.
14. This server is hosts the application and run.
15. In our project we give request from the jsp and we give the defined values to the servlets which runs in the server. The servlets takes the response and gives the expected output.
16. The values are stored in the database. And can be retrieved and deleted in future.
17. This project gives the complete information and logs the information provided.
18. We used MIRRA ,DNS, Sort and merge, profiler.
19. We also logs the time starts and time ends and it schedules that way.
20. We also logs the output, issues, action required etc.
现在我将根据行号阅读。并想将其写入新文件。例如从文件 f1.txt 中的第 1-3 行和第 3-6 行 f2.txt。我知道要写在另一个文件中。但不知道如何在java中拆分它。
BufferedReader br=new BufferedReader(new FileReader(file));
while(br.readLine()!=null)
{
String s=br.readLine();
counter++;
}
int size=counter/9;
System.out.println(counter);
for(int id=0;id<size;id++)
{
//how to split the files and read And from here no idea
}
【问题讨论】:
-
我用代码编辑过。帮助我。
-
使用 Apache Common IO FileUtil commons.apache.org/proper/commons-io/apidocs/org/apache/commons/…
标签: java filereader split