问题描述
我正在阅读下面的文本文件内容,并使用下面的代码将其写入控制台。
file content
james;mask;1980
Mos;josh;1960
我如何在新列中添加新行来计算从出生年份开始的年份
public class Readfile {
public static void main(String[] args) {
// Create file
File file = new File("/Users/James/documents/Huber.txt");
try {
// Create a buffered reader
// to read each line from a file.
BufferedReader in = new BufferedReader(new FileReader(file));
String ch;
// Read each line from the file and echo it to the screen.
while ((ch = in.readLine()) != null) {
System.out.println(ch);
}
// Close the buffered reader
in.close();
} catch (FileNotFoundException e1) {
// If this file does not exist
System.err.println("File not found: " + file);
} catch (IOException e2) {
// Catch any other IO exceptions.
e2.printStackTrace();
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)