Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Scanner;
  3.  
  4. public class Samplewriter {
  5. static File names=new File ("qwe.txt");
  6.  
  7. public static void main (String [] args) throws Exception {
  8. Scanner sc=new Scanner (System.in);
  9. String name, year, section;
  10. FileWriter writer=new FileWriter(names, true);
  11. BufferedWriter out= new BufferedWriter (writer);
  12. System.out.println ("Enter a name: ");
  13. name=sc.nextLine();
  14. System.out.println ("Enter a year: ");
  15. year=sc.nextLine();
  16.  
  17. System.out.println ("Enter a section: ");
  18. section=sc.nextLine();
  19.  
  20.  
  21. out.write(name +"," +year+ ","+ section) ;
  22. out.newLine();
  23. out.close();
  24. }
  25.  
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement