loops - Java count spesific char in file -


i need count amount of specific character in file. user specify char need check how many chars there in file.

package assignmentoneqone; import java.util.scanner; import java.io.filereader; import java.io.file; import java.io.ioexception;  /**  *  * @author hannes  */ public class assignmentoneqone {      /**      * @param args command line arguments      */     public static void main(string[] args) {         // todo code application logic here         scanner kb = new scanner(system.in);          string fileloc;         string userchar;          //user specify file , character          system.out.println("enter file name");         fileloc = kb.nextline();         system.out.println("enter character");         userchar = kb.nextline();          file file = new file(fileloc);         try         {         filereader fw = new filereader(file); 

this should search characters.

        }         catch(ioexception e)                 {                 system.out.println("the file not exist.");                 }                      } } 

using beautiful guava this... (if that's option)

        int result = charmatcher.is('t').countin("test"); //of course each line instead of 'test'     system.out.println(result); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -