Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.io.*;
- import java.util.*;
- /**
- *
- * @author IT12FC1
- */
- public class MidtermFileBio {
- public static void main(String[] args)throws IOException{
- InputStreamReader in = new InputStreamReader(System.in);
- BufferedReader bago = new BufferedReader(in);
- PrintWriter outStream = null;
- Scanner input = new Scanner (System.in);
- String fileName = null, ext = null,choice;
- String name = "Name: ", address = "Address: ", school = "School: ", alias = "Alias: ", gender = "Gender: ";
- char charChoice;
- try{
- System.out.print("Enter file name: ");
- fileName = input.nextLine();
- System.out.print("Enter a extension: ");
- ext = input.nextLine();
- outStream = new PrintWriter(new FileOutputStream(fileName+ext));
- }
- catch(FileNotFoundException e){
- System.out.println("File Not Found!\n");
- System.exit(0);
- }
- System.out.print("Name: ");
- outStream.print(name);
- name = bago.readLine();
- outStream.println(""+name);
- System.out.print("Address: ");
- outStream.print(address);
- address = bago.readLine();
- outStream.println(""+address);
- System.out.print("School: ");
- outStream.print(school);
- school = bago.readLine();
- outStream.println(""+school);
- System.out.print("Alias: ");
- outStream.print(alias);
- alias = bago.readLine();
- outStream.println(""+alias);
- System.out.print("Gender: ");
- outStream.print(gender);
- gender = bago.readLine();
- outStream.println(""+gender);
- outStream.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement