我是java新手! 我使用此代码将数据写入 .txt 文件:
try {
String content = "This is the content to write into file";
File file = new File("/users/mkyong/filename.txt");
// if file doesnt exists, then create it
if ( !file.exists() ) {
file.createNewFile();
}
FileWriter fw = new FileWriter( file.getAbsoluteFile() );
BufferedWriter bw = new BufferedWriter( fw );
bw.write( content );
bw.NewLine();
bw.close();
System.out.println("Done");
} catch (IOException e) {
e.printStackTrace();
}
名字姓氏注册号
乔
最大
1238
我想将每个数据存储在其名称下方:
我想点赞:
FName LName Reg_Num
乔最大 1238
谢谢!
最佳答案
该代码应将“This is the content to write into file”输出到文本文件中。这些名字从何而来?
用于 Java 制表 see this topic .
关于java - 将常规数据保存到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13975060/