I am new in java!
I use this code to write data to a .txt file:
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();
}
First name Lastname Registration Number
joe
max
1238
I want to store each data below the its name:
I want to like this:
FName LName Reg_Num
joe max 1238
thanks!
You can use \t to add tab between the fields. The sample code could be something like :