Print a txt file in alphabetical order and count words
well, im starting to programming and i wanna print a txt file ordered and counting all the words inside: like ( hello i have one orange and i have one apple-> apple 1/and 1/ have 2/ hello 1/ i 2/one 2/orange 1/) how could i make this? my code only prints the text and nothing else. String camino="path to txt file"; FileReader fr = new FileReader(camino+"TM.txt"); BufferedReader br = new BufferedReader(fr); int n; int mida=0; String s = br.readLine(); // reads a single line while(s!=null) { String[] t=s.split("\\s"); // split by spaces and generates an array of Strings -words- for(int i=0;i<t.length;i++){ System.out.println(t[i]); } s = br.readLine(); } br.close(); } }