Please tell me how to count from the directory (folder) all files (they are in txt format) and split their contents into words. I tried to write:
import java.io.*; import java.util.*; public class Fil { public static void main(String[] args) throws IOException { File files = new File("C://Instructions"); List < String > textFiles = new ArrayList < String > (); for (File file: files.listFiles()) { try { BufferedReader br = new BufferedReader(new FileReader(file)); String str = br.readLine(); StringTokenizer st = new StringTokenizer(str); while (st.hasMoreTokens()) { System.out.println(st.nextToken()); } } } catch (IOException e) { e.printStackTrace(); } } } }