Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. import java.io.*;
  7. import java.util.*;
  8. /**
  9. *
  10. * @author IT12FC1
  11. */
  12. public class MidtermFileBio {
  13. public static void main(String[] args)throws IOException{
  14. InputStreamReader in = new InputStreamReader(System.in);
  15. BufferedReader bago = new BufferedReader(in);
  16. PrintWriter outStream = null;
  17. Scanner input = new Scanner (System.in);
  18. String fileName = null, ext = null,choice;
  19. String name = "Name: ", address = "Address: ", school = "School: ", alias = "Alias: ", gender = "Gender: ";
  20. char charChoice;
  21. try{
  22. System.out.print("Enter file name: ");
  23. fileName = input.nextLine();
  24. System.out.print("Enter a extension: ");
  25. ext = input.nextLine();
  26. outStream = new PrintWriter(new FileOutputStream(fileName+ext));
  27. }
  28. catch(FileNotFoundException e){
  29. System.out.println("File Not Found!\n");
  30. System.exit(0);
  31. }
  32.  
  33.  
  34.  
  35.  
  36. System.out.print("Name: ");
  37. outStream.print(name);
  38. name = bago.readLine();
  39. outStream.println(""+name);
  40.  
  41. System.out.print("Address: ");
  42. outStream.print(address);
  43. address = bago.readLine();
  44. outStream.println(""+address);
  45.  
  46. System.out.print("School: ");
  47. outStream.print(school);
  48. school = bago.readLine();
  49. outStream.println(""+school);
  50.  
  51. System.out.print("Alias: ");
  52. outStream.print(alias);
  53. alias = bago.readLine();
  54. outStream.println(""+alias);
  55.  
  56. System.out.print("Gender: ");
  57. outStream.print(gender);
  58. gender = bago.readLine();
  59. outStream.println(""+gender);
  60. outStream.close();
  61.  
  62.  
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement