Checking of a line is in a file with bufferedread and hashset
My problem is that I have to write code to check if a customers name is already in my txt file (Customers.txt).

The problem is that I check with hashset if the customer is in the file and he says that he isn't in the file while he is.(Checked it manually)
Please help me solve this.

The code that I already have is below.

        public class Customer {
    	//declaration
    	public static String S;
    	private String line ;
    	public String nameCustomer;
    	
    	
    /**
     * constructor
     */
    public Klant(){}
    	
    /**Checking of the customer is in the file
     */
    public void getCustomer() {
        // make SimpleInOutDialog      
            SimpleInOutDialog  input = new SimpleInOutDialog("Customers");
            nameCustomer = input.readString("Give in the name");
        try{
        BufferedReader br = new BufferedReader(new FileReader("L:\\Documents/Informatica/6de jaar/GIP/Customers.txt"));
        HashSet<String> hs = new HashSet<String>();
        int i = 0;
        while ((line = br.readLine()) != null)
        {
            i++;
            if (i == 1){hs.add(br.readLine());}
    
            if (i % 4 == 0){hs.add(br.readLine());}
    
        }
        if(hs.contains(nameCustomer)){
            //the customer exists
         input.showString("The customer exists", "");
         }else{input.showString("The customer does not exist, we will make a new one", "");
        	 setNieuweKlant();}
    
    
        }catch (Exception e){//Catch when there are errors
            System.err.println("Error: " + e.getMessage());}
    
    }
    
    	
    /**
     * make a new customer
     */
    
    public void Make new customer(){
        // make SimpleInOutDialog     
    	SimpleInOutDialog  input = new SimpleInOutDialog("A new customer");
    	//input
    	S = "Name customer: " + input.readString("Give in your name:");
    WriteToFile();
    S = "Adress: " + input.readString("Give your adress");
    WriteToFile();
    S = "Telephonenummber: " + input.readString("Give your telephonenumber");
    WriteToFile();
    //making a customerID
      UUID idCustomer = UUID.randomUUID();  
    S = "CustomerID: " + customerID.toString();
    WriteToFile();
    	
    }
    	
    	
    /**
     * Schrijft de gegevens weg naar het bestand
     */
  

     public void WriteToFile(){
    try{

    FileWriter writer = new FileWriter("L:\\Documents/Informatica/6de jaar/GIP/Customer.txt", true);
    BufferedWriter out = new BufferedWriter(writer);
    //Wrting away your data
    out.write(S);

    //Closing the writer
    out.close();


    }catch (Exception e){//Catch when there are errors
        System.err.println("Error: " + e.getMessage());
        }
        }
Checking of a line is in a file with bufferedread and hashset
===

My problem is that I have to write code to check if a customers name is already in my txt file (Customers.txt).

The problem is that I check with hashset if the customer is in the file and he says that he isn't in the file while he is.(Checked it manually)
Please help me solve this.

The code that I already have is below.

        public class Customer {
    	//declaration
    	public static String S;
    	private String line ;
    	public String nameCustomer;
    	
    	
    /**
     * constructor
     */
    public Klant(){}
    	
    /**Checking of the customer is in the file
     */
    public void getCustomer() {
        // make SimpleInOutDialog      
            SimpleInOutDialog  input = new SimpleInOutDialog("Customers");
            nameCustomer = input.readString("Give in the name");
        try{
        BufferedReader br = new BufferedReader(new FileReader("L:\\Documents/Informatica/6de jaar/GIP/Customers.txt"));
        HashSet<String> hs = new HashSet<String>();
        int i = 0;
        while ((line = br.readLine()) != null)
        {
            i++;
            if (i == 1){hs.add(br.readLine());}
    
            if (i % 4 == 0){hs.add(br.readLine());}
    
        }
        if(hs.contains(nameCustomer)){
            //the customer exists
         input.showString("The customer exists", "");
         }else{input.showString("The customer does not exist, we will make a new one", "");
        	 setNieuweKlant();}
    
    
        }catch (Exception e){//Catch when there are errors
            System.err.println("Error: " + e.getMessage());}
    
    }
    
    	
    /**
     * make a new customer
     */
    
    public void Make new customer(){
        // make SimpleInOutDialog     
    	SimpleInOutDialog  input = new SimpleInOutDialog("A new customer");
    	//input
    	S = "Name customer: " + input.readString("Give in your name:");
    WriteToFile();
    S = "Adress: " + input.readString("Give your adress");
    WriteToFile();
    S = "Telephonenummber: " + input.readString("Give your telephonenumber");
    WriteToFile();
    //making a customerID
      UUID idCustomer = UUID.randomUUID();  
    S = "CustomerID: " + customerID.toString();
    WriteToFile();
    	
    }
    	
    	
    /**
     * Schrijft de gegevens weg naar het bestand
     */
  

     public void WriteToFile(){
    try{

    FileWriter writer = new FileWriter("L:\\Documents/Informatica/6de jaar/GIP/Customer.txt", true);
    BufferedWriter out = new BufferedWriter(writer);
    //Wrting away your data
    out.write(S);

    //Closing the writer
    out.close();


    }catch (Exception e){//Catch when there are errors
        System.err.println("Error: " + e.getMessage());
        }
        }