// Count on many "I" appear in the posts on my student blog // based on Daniel Shiffman code - A2Z import java.io.*; import java.nio.*; import java.nio.channels.*; public class Exercise2 { public static void main (String[] args) throws IOException { // Create an input stream and file channel // Using first argument as file name to read in FileInputStream fis = new FileInputStream(args[0]); FileChannel fc = fis.getChannel(); // Read the contents of a file into a ByteBuffer ByteBuffer bb = ByteBuffer.allocate((int)fc.size()); fc.read(bb); fc.close(); // Convert ByteBuffer to one long String String content = new String(bb.array()); // This line uses a regular expression which we haven't learned yet // '\\b' means split the text along word boundaries // We will cover this in more detail next week String[] words = content.split("\\b"); StringBuffer CountIs = new StringBuffer(); StringBuffer PhrasesIs = new StringBuffer(); for ( int a = 0; a