0

I have done do the code below for take 5 user input and print it out . Now i wanna to take the input from users and save it on to file, and retrieve it back . Pleas i need to explain who i can do this .

Thanks and regards

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class user_info {

    public static void main(String[] args) throws Exception {

        int i;
        String Uname;
        int UIDnum;
        user_input[] input = new user_input[5];
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        for (i = 0; i < input.length; i++) {
            input[i] = new user_input();
            int number = i + 1;
            System.out.println("User:" + number);
            System.out.println("Please Enter your name:");
            Uname = br.readLine();
            input[i].setName(Uname);

            System.out.println("Please Enter your ID number:");
            UIDnum = Integer.parseInt(br.readLine());
            input[i].setIDnum(UIDnum);

        }
                          //char n = (char)UIDnum;
        //String u = Integer.toString(UIDnum);

        for (i = 0; i < input.length; i++) {

            System.out.println("your name:" + input[i].getName());
            System.out.println("your ID number:" + input[i].getIDnum());

        }

    }
}
  • http://stackoverflow.com/documentation/java/93/file-i-o/10225/file-read-write-using-fileinputstream-fileoutputstream#t=201611200948052857906 – denvercoder9 Nov 20 '16 at 09:48
  • 4
    Possible duplicate of [How to create a file and write to a file in Java?](http://stackoverflow.com/questions/2885173/how-to-create-a-file-and-write-to-a-file-in-java) – Joe C Nov 20 '16 at 09:48

1 Answers1

0

Possibly you can have a look at the specified below link:

https://www.caveofprogramming.com/java/java-file-reading-and-writing-files-in-java.html

Akash Chugh
  • 65
  • 2
  • 8