Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. // Application Text counts the occurrence of all characters
  2. // in a text file
  3. import java.util.Scanner;
  4. import java.io.*;
  5. public class Text
  6. {
  7. public static void main(String[] args) throws IOException
  8. {
  9. int[] charCount;
  10. charCount = new int[256]; // Contains character counts
  11. char[] lineArray;
  12.  
  13. int index;
  14. int charIndex;
  15. String line;
  16. Scanner inFile;
  17. inFile = new Scanner(new FileReader("C:\\Users\\Nick\\Downloads\\LabData\\Chap9.pro\\Text.dat"));
  18.  
  19. while (inFile.hasNextLine())
  20. {
  21. line = inFile.nextLine();
  22. for (index = 0; index < line.length(); index++)
  23. {
  24. charIndex = line.charAt(index);
  25. charCount[charIndex]= charCount[charIndex] + 1;
  26. }
  27. {
  28. for (index = 0; index < charCount.length; index++)
  29. {
  30. /* TO BE FILLED IN: Exercise 6 */
  31. }
  32. }
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement