Niloy007

FinalSampleProb3

Dec 14th, 2019
92
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedReader;
  2. import java.io.BufferedWriter;
  3. import java.io.FileReader;
  4. import java.io.IOException;
  5.  
  6. public class ThirdSolution {
  7.     public static void main(String[] args) {
  8.         FileReader fileReader;
  9.         BufferedReader bufferedReader;
  10.         int count = 0;
  11.  
  12.         try {
  13.             fileReader = new FileReader("/Niloy/Test/src/SampleSolution/text.txt");
  14.             bufferedReader = new BufferedReader(fileReader);
  15.  
  16.             String a;
  17.             String c = "in";
  18.             while((a = bufferedReader.readLine()) != null) {
  19.                 String[] array = a.split(" ");
  20.  
  21.                 for(String b : array) {
  22.                     if(b.equals(c)) {
  23.                         ++count;
  24.                     }
  25.                 }
  26.             }
  27.             System.out.println(count);
  28.         } catch (IOException e) {
  29.  
  30.         }
  31.     }
  32. }
RAW Paste Data