public void CheckChatHistory(String currentUser) {

        String path = "resources/"; 

        String files;
        File folder = new File(path);
        File[] listOfFiles = folder.listFiles(); 

        //list all the files
        for (int i = 0; i < listOfFiles.length; i++) 
        {
            //check if it is not a folder
            if (listOfFiles[i].isFile()) 
            {
                files = listOfFiles[i].getName();
                //check the extention of the file
                if (files.endsWith(".txt"))
                {
                    //look if the user have old chat
                    if(files.matches(currentUser+"-.*")){
                        //Reconized the name of the sender user
                        String nameOfUser[] = files.split("-");
                        nameOfUser = nameOfUser[1].split(".txt");
                        System.out.println(nameOfUser[0]);
                        
                        //***********read the line **********//
                        try{

                            BufferedReader br = new BufferedReader(
                                                    new InputStreamReader(
                                                        new FileInputStream(path+files)));
                            String ligne;
                            while ((ligne = br.readLine())!=null){
                                writeMessageToOnlineUser(currentUser, nameOfUser[0], ligne);
                            }
                            
                           File f = new File(path+files);
                           boolean success = f.delete();

                            if (!success)
                            throw new IllegalArgumentException("Delete: deletion failed");
  
                    }
                    catch (Exception e){
                            System.out.println(e.toString());
                    }
                        
                        
                        
                        
                        //*********************//
                    }
                }
            }
        }
  
    }