需求是用java程序获取txt文件中的数据并将姓名、职称、工资添加到新txt文件中,txt文件中数据的格式是固定的,如下:
添加后的格式是这样的:
这里不考虑工资是怎么算的,只说获取数据和写入数据的方法。
教师姓名和职称之间有一个空格,职称和下一位教师之间有一条新的界线。
[En]
There is a space between the teacher's name and professional title, and there is a new line between the professional title and the next teacher.
通过查阅资料,我发现了一种特别有趣的思维方式。我写的代码如下:
[En]
Through consulting materials, I found a particularly interesting way of thinking. The code I wrote is as follows:
```
public class Main {
public static void main(String[] args) throws IOException {
InputStream in = null;
InputStreamReader reader =null;
FileOutputStream fop = null;