Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Application Text counts the occurrence of all characters
- // in a text file
- import java.util.Scanner;
- import java.io.*;
- public class Text
- {
- public static void main(String[] args) throws IOException
- {
- int[] charCount;
- charCount = new int[256]; // Contains character counts
- char[] lineArray;
- int index;
- int charIndex;
- String line;
- Scanner inFile;
- inFile = new Scanner(new FileReader("C:\\Users\\Nick\\Downloads\\LabData\\Chap9.pro\\Text.dat"));
- while (inFile.hasNextLine())
- {
- line = inFile.nextLine();
- for (index = 0; index < line.length(); index++)
- {
- charIndex = line.charAt(index);
- charCount[charIndex]= charCount[charIndex] + 1;
- }
- {
- for (index = 0; index < charCount.length; index++)
- {
- /* TO BE FILLED IN: Exercise 6 */
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement