Advertisement
ZlatniotOdBaba

HW01_4

Mar 3rd, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileInputStream;
  3. import java.io.IOException;
  4. import java.io.InputStreamReader;
  5.  
  6. public class HW01_4 {
  7.  
  8.     public static void main(String[] args) throws IOException {
  9.         // TODO Auto-generated method stub
  10.         BufferedReader bi=null;
  11.        
  12.         try{
  13.         bi=new BufferedReader(new InputStreamReader(new FileInputStream(args[0]),"UTF-8"));
  14.        
  15.         //StringBuilder sb=new StringBuilder();
  16.         String line=null;
  17.         int suma=0;
  18.         while((line=bi.readLine())!=null)
  19.         {
  20.             if(line.toLowerCase().contains(args[1].toLowerCase().trim())){
  21.             String[] niza=line.split(" ");
  22.             for(int i=0;i<niza.length;i++){
  23.             if((niza[i].toLowerCase().trim()).equals(args[1].toLowerCase().trim()))
  24.                 suma++;
  25.             }
  26.             }
  27.         }
  28.         System.out.print(suma);
  29.         }
  30.         finally{
  31.             bi.close();
  32.        
  33.            
  34.         }
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement