java获取txt文件中以空格分割的字符串

Java57

需求是用java程序获取txt文件中的数据并将姓名、职称、工资添加到新txt文件中,txt文件中数据的格式是固定的,如下:

java获取txt文件中以空格分割的字符串

添加后的格式是这样的:

java获取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;

输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长