I'm trying to write a program which will take user input from a list of options then either:
- write to a file
- alter an existing file or
- delete a file.
At the moment I'm stuck on just writing to the file from the user input. I have to use regex notation for each of the users input as seen in the snippet. Any help or guidance on what i could do will be highly appreciated, and yes there are a lot of errors right now. Thanks!
import java.io.*;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
private UserInput[] list;
class Input {
    public static void main(String[] args) {
        Scanner in = (System.in);
        string Exit ="False"; 
        System.out.println("person details");
        System.out.println("");
        System.out.println("Menu Options:");
        System.out.println("1. Add new person");
        System.out.println("2. Load person details ");
        System.out.println("3. Delete person Entry");
        System.out.print("Please select an option from 1-5\r\n");
        int choice = in.nextLine();
        if (choice == 1)
            system.out.println("you want to add a new person deails.");
            AddStudnet(); 
       else if (choice == 2){
            system.println("would you like to: ");
            system.println("1. Load a specific entry");
            system.println("2. Load ");
        }
//Error checking the options
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            int input = Integer.parseInt(br.readLine());
            if(input < 0 || input > 5) {
                System.out.println("You have entered an invalid selection, please try again\r\n");
            } else if(input == 5) {
                System.out.println("You have quit the program\r\n");
                System.exit(1);
            } else {
                System.out.println("You have entered " + input + "\r\n");
            }
        } catch (IOException ioe) {
            System.out.println("IO error trying to read your input!\r\n");
            System.exit(1);
        }
    }
}
//Scanner reader = new Scanner(System.in);{  // Reading from System.in
//System.out.println("Please enter your name: ");
//String n = reader.nextLine();
//}
  //      File file = new File("someFile.txt", True);
    //    FileWriter writer = new FileWriter(file);
      //  writer.write(reader);
//        writer.close();
public static void addPerson(String args[]) throws IOException{
    class input Per{
    scanner in = new scanner (system.in);
    system.out.print("Please enter you Name: ");
     String name = in.nextLine()
     final Pattern pattern = Pattern.compile("/^[a-z ,.'-]+$/i");
     if (!pattern.matcher(name).matches()) {
        throw new IllegalArgumentException("Invalid String");
     //String Name = regex ("Name")
     //regex below for formatting
    system.out.println("Please enter your Job title:");
    //String CourseNum = regex ("JobTitle");
    system.out.println("Please enter your Town:");
   //String Town = regex("Town");
    system.out.println("Please enter your postcocde:");
    //String postcocde = regex("postcocde");
    system.out.println("Please enter your street:");
    //String Street = regex ("Street");
    system.out.println("Please enter your House Number:");
    //String HouseNum = regex ("HouseNum");
    }
}
//public static void
 
     
    