Assignment #126

   ///Name: Sam Wilson
   ///Period: 6
   ///Program Name: Getting All The Data From a File
   ///File Name: getdata.java
   ///Date Finished: 6/1/16
    
    
 import java.io.File;
    import java.util.Scanner;
    
    public class getdata
    {
    
        public static void main(String[] args) throws Exception
        {
    
            int fourLetter = 0;
            int caps = 0;
    
            String fn1 = "some-words.txt";
            String fn2 = "GettingWholeFile.java";
    
            Scanner wordReader = new Scanner(new File(fn1));
            
            System.out.println();
    
            while(wordReader.hasNext()) {
    
                String w = wordReader.next();
    
                if(w.length() == 4)
                    fourLetter++;
            }
    
            wordReader.close();
    
            Scanner selfInput = new Scanner(new File(fn2));
    
            while(selfInput.hasNext()) {
    
                String token = selfInput.next();
    
                if(Character.isUpperCase(token.charAt(0)))
                    caps++;
            }
    
            selfInput.close();
    
            System.out.println( fourLetter + " four-letter words in " + fn1);
            System.out.println( caps + " words start with capitals in " + fn2);
            System.out.println();
            
            // This Comment is serving A Purpose
        }
    }
  
    
    

Picture of the output

Assignment #126