EvilZone

Programming and Scripting => Java => : Packment June 20, 2014, 12:18:14 PM

: Java Character counter from txtfile
: Packment June 20, 2014, 12:18:14 PM
This code have error somewhere around dnt knw what to do next
Please help me out

:
Import java.io.*;
Import java.util.Scanner;


Public class txtCharacter{
Public static Scanner kb = new Scanner;


Public static void  main(String args[])throws IOException{


  .   Scanner in = new Scanner(new FileReader("file locatio");
      char Character;


      System.out.println("Enter character to count");
      Character = kb.nextLineCharAt(0);


  while(in.hasNext){
  .  String line = in.readLine();
  .  int count;
     if(Character=!' '){
         counter++;
       }
  }
System.out.println("The number of occurrence: "+ count);
 }
In.close();
}
: Re: Java Character counter from txtfile
: ThePH30N1X June 20, 2014, 12:51:01 PM
: (Java)
import java.io.*;
import java.util.Scanner;


public class txtCharacter {

public static Scanner kb = new Scanner(System.in);


public static void main(String args[])throws IOException{


  .   Scanner in = new Scanner(new FileReader("file locatio"));
      char Character;


      System.out.println("Enter character to count");
      Character = kb.nextLineCharAt(0);


  while(in.hasNext){
    String line = in.readLine();
    int count;
     if(Character != ' '){
         count++;
       }
  }
System.out.println("The number of occurrence: "+ count);
 }
in.close();
}
Try that. I haven't tested it though.
: Re: Java Character counter from txtfile
: Deque June 20, 2014, 03:05:45 PM
This code have error somewhere around dnt knw what to do next
Please help me out

:
Import java.io.*;
Import java.util.Scanner;


Public class txtCharacter{
Public static Scanner kb = new Scanner;


Public static void  main(String args[])throws IOException{


  .   Scanner in = new Scanner(new FileReader("file locatio");
      char Character;


      System.out.println("Enter character to count");
      Character = kb.nextLineCharAt(0);


  while(in.hasNext){
  .  String line = in.readLine();
  .  int count;
     if(Character=!' '){
         counter++;
       }
  }
System.out.println("The number of occurrence: "+ count);
 }
In.close();
}

Where did you get this pile of shit from?
Seriously, this is worse than any code of any programming beginner in Java. It looks like copy&pasted from code in another language with an effortless try to transform it to Java. Learn the basics about Java and you might get anywhere.