Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Solution {
- public static void main(String[] args) {
- try
- {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String fileName = reader.readLine();
- reader.close();
- reader = new BufferedReader(new FileReader(fileName));
- int count = 0;
- while(reader.ready())
- {
- String[] input = reader.readLine().split(" ");
- for (String s : input)
- {
- if(s.matches("^world\\p{Punct}*"))
- count++;
- }
- }
- System.out.println(count);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement