Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- class FileSave
- {
- public static void main(String ar[])
- {
- Scanner sc=new Scanner(System.in);
- System.out.println("Enter the ID:");
- String id=sc.nextLine();
- System.out.println("Enter the first name:");
- String fn=sc.nextLine();
- System.out.println("Enter the last name:");
- String ln=sc.nextLine();
- System.out.println("Enter the salary:");
- String sl=sc.nextLine();
- System.out.println("Enter the location:");
- String lc=sc.nextLine();
- try
- {
- File f=new File("Database.txt");
- PrintWriter pw=new PrintWriter(new FileOutputStream(f,true));
- pw.append("\n"+id+","+fn+","+ln+","+sl+","+lc);
- pw.close();
- }
- catch(Exception e){}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement