READING DATA FROM MULTIPLE TEXT FILES
I AM NEW TO JAVA PROGRAMMING , I AM TRYING TO PRINT NAMES, READ MULTIPLE TEXT FILES FROM A FOLDER AND COUNTING WORD FREQUENCY OF EACH WORD FILE WISE, NOW WHEN I M READING A FOLDER ALL THE TEXT FILES ARE PRINTED BUT THEY ARE NOT READ ..LOOK AT THE CODE.

    import java.io.*;
    import java.util.StringTokenizer;
    import java.util.TreeMap;
    public class foldersearch
    {
     
     public static void main(String[] args) 
    {
     
      // Directory path here
      String path = "/home/sumeet/Documents/text files"; 
     
      String files;
      File folder = new File(path);
      File[] listOfFiles = folder.listFiles(); 
     
      for (int i = 0; i < listOfFiles.length; i++) 
      {
     
       if (listOfFiles[i].isFile()) 
       {
       files = listOfFiles[i].getName();
       if (files.endsWith(".txt") || files.endsWith(".TXT"))
       {
    	   System.out.println(files);
    		 TreeMap<String, Integer> frequencyMap = new TreeMap<String, Integer>(); 
    
    			
    			String currentLine="";
    		
    
    	 **File textFile = new File(files);** // SOME CHANGE IS REQUIRED HERE..?
    	try{
    
    	     BufferedReader br = new BufferedReader(new FileReader(textFile)); 
    
    	    while ((currentLine = br.readLine()) != null) { 
    	                 currentLine = currentLine.toLowerCase(); 
    	               StringTokenizer parser = new StringTokenizer(currentLine, " \t\n\r\f.,;:!?'"); 
    	                   while (parser.hasMoreTokens()) { 
                             String currentWord = parser.nextToken(); 
    	                       Integer frequency = frequencyMap.get(currentWord); 
    	                                     if (frequency == null) { 
    	                                               frequency = 0; 
    	                                                                                                 } 
    	                                      frequencyMap.put(currentWord, frequency + 1); 
    
    	                           } 
    
    
    	}br.close(); }
    	catch (FileNotFoundException e) {
    		   System.out.println(e.getMessage());
    	} catch (IOException e) {
    		// TODO Auto-generated catch block
    		e.printStackTrace();
    	}
    	System.out.println(frequencyMap);
    	}
    	   
    	   
          }
      }
    }
    }
    
    **OUTPUT**
    
    nokia.txt
    nokia.txt (No such file or directory)
    {}
    MainClass.txt
    MainClass.txt (No such file or directory)
    {}
    2b.txt
    2b.txt (No such file or directory)
    {}
    cn exercise 2.txt
    cn exercise 2.txt (No such file or directory)
    {}
    2c.txt
    2c.txt (No such file or directory)
    {}
    dummy.txt
    dummy.txt (No such file or directory)
    {}
    readme.txt
    readme.txt (No such file or directory)
    {}
    Kb.txt
    Kb.txt (No such file or directory)
    {}
    all.txt
    all.txt (No such file or directory)
    {}
    1b.txt
    1b.txt (No such file or directory)
    {}
    todo.txt
    todo.txt (No such file or directory)
    {}
    1c.txt
    1c.txt (No such file or directory)
    {}
    2a.txt
    2a.txt (No such file or directory)
    {}
    USE CASE.txt
    USE CASE.txt (No such file or directory)
    {}


READING DATA FROM MULTIPLE TEXT FILES
===

I AM NEW TO JAVA PROGRAMMING , I AM TRYING TO PRINT NAMES, READ MULTIPLE TEXT FILES FROM A FOLDER AND COUNTING WORD FREQUENCY OF EACH WORD FILE WISE, NOW WHEN I M READING A FOLDER ALL THE TEXT FILES ARE PRINTED BUT THEY ARE NOT READ ..LOOK AT THE CODE.

    import java.io.*;
    import java.util.StringTokenizer;
    import java.util.TreeMap;
    public class foldersearch
    {
     
     public static void main(String[] args) 
    {
     
      // Directory path here
      String path = "/home/sumeet/Documents/text files"; 
     
      String files;
      File folder = new File(path);
      File[] listOfFiles = folder.listFiles(); 
     
      for (int i = 0; i < listOfFiles.length; i++) 
      {
     
       if (listOfFiles[i].isFile()) 
       {
       files = listOfFiles[i].getName();
       if (files.endsWith(".txt") || files.endsWith(".TXT"))
       {
    	   System.out.println(files);
    		 TreeMap<String, Integer> frequencyMap = new TreeMap<String, Integer>(); 
    
    			
    			String currentLine="";
    		
    
    	 **File textFile = new File(files);** // SOME CHANGE IS REQUIRED HERE..?
    	try{
    
    	     BufferedReader br = new BufferedReader(new FileReader(textFile)); 
    
    	    while ((currentLine = br.readLine()) != null) { 
    	                 currentLine = currentLine.toLowerCase(); 
    	               StringTokenizer parser = new StringTokenizer(currentLine, " \t\n\r\f.,;:!?'"); 
    	                   while (parser.hasMoreTokens()) { 
                             String currentWord = parser.nextToken(); 
    	                       Integer frequency = frequencyMap.get(currentWord); 
    	                                     if (frequency == null) { 
    	                                               frequency = 0; 
    	                                                                                                 } 
    	                                      frequencyMap.put(currentWord, frequency + 1); 
    
    	                           } 
    
    
    	}br.close(); }
    	catch (FileNotFoundException e) {
    		   System.out.println(e.getMessage());
    	} catch (IOException e) {
    		// TODO Auto-generated catch block
    		e.printStackTrace();
    	}
    	System.out.println(frequencyMap);
    	}
    	   
    	   
          }
      }
    }
    }
    
    **OUTPUT**
    
    nokia.txt
    nokia.txt (No such file or directory)
    {}
    MainClass.txt
    MainClass.txt (No such file or directory)
    {}
    2b.txt
    2b.txt (No such file or directory)
    {}
    cn exercise 2.txt
    cn exercise 2.txt (No such file or directory)
    {}
    2c.txt
    2c.txt (No such file or directory)
    {}
    dummy.txt
    dummy.txt (No such file or directory)
    {}
    readme.txt
    readme.txt (No such file or directory)
    {}
    Kb.txt
    Kb.txt (No such file or directory)
    {}
    all.txt
    all.txt (No such file or directory)
    {}
    1b.txt
    1b.txt (No such file or directory)
    {}
    todo.txt
    todo.txt (No such file or directory)
    {}
    1c.txt
    1c.txt (No such file or directory)
    {}
    2a.txt
    2a.txt (No such file or directory)
    {}
    USE CASE.txt
    USE CASE.txt (No such file or directory)
    {}

