Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. public class Solution {
  2.     public static void main(String[] args) {
  3.         try
  4.         {
  5.             BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  6.             String fileName = reader.readLine();
  7.             reader.close();
  8.             reader = new BufferedReader(new FileReader(fileName));
  9.             int count = 0;
  10.             while(reader.ready())
  11.             {
  12.                 String[] input = reader.readLine().split(" ");
  13.                 for (String s : input)
  14.                 {
  15.                     if(s.matches("^world\\p{Punct}*"))
  16.                         count++;
  17.                 }
  18.             }
  19.             System.out.println(count);
  20.         }
  21.         catch (IOException e)
  22.         {
  23.             e.printStackTrace();
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement