java num

java num

Write a Java program to find the number of characters in a file

View Answers

April 26, 2011 at 10:41 AM

import java.io.*;
import java.util.*;

class CountCharactersFromFile {
        public static void main(String[] args) throws Exception {
            int countch=0;
                BufferedReader br = new BufferedReader(new FileReader("C:/data.txt"));
                String strLine = "";
                String str = "";
                while ((strLine = br.readLine()) != null) {
                        str += strLine;
                }
                String st = str.replaceAll(" ", "").toLowerCase();
                char[] third = st.toCharArray();
                System.out.println("Character   Total");
                for (int counter = 0; counter < third.length; counter++) {
                        char ch = third[counter];
                        int count = 0;
                        for (int i = 0; i < third.length; i++) {
                                if (ch == third[i])
                                        count++;
                        }
                        boolean flag = false;
                        for (int j = counter - 1; j >= 0; j--) {
                                if (ch == third[j])
                                        flag = true;
                        }
                        if (!flag) {
                                System.out.println(ch + "              " + count);
                        }
                        countch++;
                }
                System.out.println("Total number of characters: "+countch);
        }
}









Related Tutorials/Questions & Answers:
java num
java num  Write a Java program to find the number of characters in a file
find largest num enter by user using loop method - Java Interview Questions
find largest num enter by user using loop method  hi..it's me again.. thanks for answering my question.. i wanna ask, if i wanna use loop in the part: int a, b, c, d, e; Scanner in = new Scanner(System.in
Advertisements
Diamond shape num - Java Interview Questions
ModuleNotFoundError: No module named 'num_calculus'
ModuleNotFoundError: No module named 'num_calculus'  Hi, My Python... 'num_calculus' How to remove the ModuleNotFoundError: No module named 'num_calculus' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'num-fh'
ModuleNotFoundError: No module named 'num-fh'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'num-fh' How to remove the ModuleNotFoundError: No module named 'num-fh'
ModuleNotFoundError: No module named 'num-radix'
ModuleNotFoundError: No module named 'num-radix'  Hi, My Python... 'num-radix' How to remove the ModuleNotFoundError: No module named 'num... have to install padas library. You can install num-radix python with following
ModuleNotFoundError: No module named 'num-shorty'
ModuleNotFoundError: No module named 'num-shorty'  Hi, My Python... 'num-shorty' How to remove the ModuleNotFoundError: No module named 'num... have to install padas library. You can install num-shorty python
ModuleNotFoundError: No module named 'num-solver'
ModuleNotFoundError: No module named 'num-solver'  Hi, My Python... 'num-solver' How to remove the ModuleNotFoundError: No module named 'num... have to install padas library. You can install num-solver python
ModuleNotFoundError: No module named 'num-thai'
ModuleNotFoundError: No module named 'num-thai'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'num-thai' How to remove the ModuleNotFoundError: No module named 'num-thai
ModuleNotFoundError: No module named 'big-num-format'
ModuleNotFoundError: No module named 'big-num-format'  Hi, My... named 'big-num-format' How to remove the ModuleNotFoundError: No module named 'big-num-format' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'date-from-num'
ModuleNotFoundError: No module named 'date-from-num'  Hi, My... 'date-from-num' How to remove the ModuleNotFoundError: No module named 'date-from-num' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'hn-test-num'
ModuleNotFoundError: No module named 'hn-test-num'  Hi, My Python... 'hn-test-num' How to remove the ModuleNotFoundError: No module named 'hn-test-num' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'Num-CFS-Cluster'
ModuleNotFoundError: No module named 'Num-CFS-Cluster'  Hi, My... named 'Num-CFS-Cluster' How to remove the ModuleNotFoundError: No module named 'Num-CFS-Cluster' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'num-to-str-repr'
ModuleNotFoundError: No module named 'num-to-str-repr'  Hi, My... named 'num-to-str-repr' How to remove the ModuleNotFoundError: No module named 'num-to-str-repr' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'random-num-py'
ModuleNotFoundError: No module named 'random-num-py'  Hi, My... 'random-num-py' How to remove the ModuleNotFoundError: No module named 'random-num-py' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'two-num-sum'
ModuleNotFoundError: No module named 'two-num-sum'  Hi, My Python... 'two-num-sum' How to remove the ModuleNotFoundError: No module named 'two-num-sum' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'two-num-sum'
ModuleNotFoundError: No module named 'two-num-sum'  Hi, My Python... 'two-num-sum' How to remove the ModuleNotFoundError: No module named 'two-num-sum' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'big-num-format'
ModuleNotFoundError: No module named 'big-num-format'  Hi, My... named 'big-num-format' How to remove the ModuleNotFoundError: No module named 'big-num-format' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'date-from-num'
ModuleNotFoundError: No module named 'date-from-num'  Hi, My... 'date-from-num' How to remove the ModuleNotFoundError: No module named 'date-from-num' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'hn-test-num'
ModuleNotFoundError: No module named 'hn-test-num'  Hi, My Python... 'hn-test-num' How to remove the ModuleNotFoundError: No module named 'hn-test-num' error? Thanks   Hi, In your python environment
Php Sql num rows
Php Sql num rows      .... In this example, we have created a num_rows.php file in which we executed a query..._num_rows() method.ADS_TO_REPLACE_1      ADS_TO_REPLACE_2 Table
PDO Fetch Num
PDO Fetch Num: We've discussed in the previous tutorial about PDO::FETCH_ASSOC, similarly PDO provides another function which returns the numerical... $result=$stmt->fetch(PDO::FETCH_NUM); echo "<table border=1>"
i have installed oracle 10g (both ee and xe) editions... while am installing i found port num as 1521 for ee, 1522 for xe
i have installed oracle 10g (both ee and xe) editions... while am installing i found port num as 1521 for ee, 1522 for xe  i have installed oracle 10g (both ee and xe) editions... while am installing i found port num as 1521
Num Sum
Num Sum       Easy, Sharable Web Spreadsheets, like google spreadsheets. Great for teams, clubs & your crew,Track all your group data together,Easy and super simple to use Read full
Hello Friends This Is Suresh .My mail id is [email protected] ,my num is +91-8500123410.
Php Sql num rows
Php Sql num rows This example illustrates how to find number of rows... and find the number of rows of the table by mysql_num_rows methods. The output...;ADS_TO_REPLACE_2 Source Code of num_rows.php  <
Java Program - Java Beginners
Java Program  Write a java program to find out the sum of digits... num; System.out.print("Enter a multidigit number: "); num = input.nextInt(); int sum = 0; while (num
JAVA PROGRAM - Java Beginners
JAVA PROGRAM  TO FIND OUT MINIMUM AND MAXIMUM NUMBERS... static void main(String[] args) { int []num={100,20,152,24,456,651,258,35}; int max = num[0]; int min = num[0]; for (int i=1; i max
Java Programming - Java Beginners
Java Programming  To find out minimum and maximum numbers in an array... getLargestNumber{ public static void main(String[] args) { int []num={100,20,152,24,456,651,258,35}; int max = num[0]; int min = num[0]; for (int i=1; i
java program - Java Beginners
java program  program to get an output i.e., is: INPUT..." }; private String oneThousand(int num) { String str; if (num % 100 < 20){ str = oneWords[num % 100]; num /= 100; } else
Java Coding Problem - Java Beginners
Java Coding Problem  Q.1 How to write a while loop that displays...[]) { int num=1; while(num<=40) { if(num%2==0) { System.out.print(" " + num + " "); } num++; } } } Solution 2 : import
corejava - Java Beginners
num) { String str; if (num % 100 < 20){ str = oneWords[num % 100]; num /= 100; } else { str = oneWords[num % 10]; num /= 10; str = tensWords[num % 10] + str
java using Stack - Java Beginners
java using Stack  How convert decimal to binary using stack in java? whats the java program or code to that. Thank you rose india and java... the number: "); int num = input.nextInt(); Stack stack = new Stack
Java Program - Java Beginners
Java Program  Write a program to compute sum of digits of a given... = new Scanner(System.in); int num; System.out.print("Enter a multidigit number: "); num = input.nextInt
Java Code - Java Beginners
Java Code  Code the declaration for an array of ints named counts... static void main(String[] args){ int num[] = {50,20,45,82,25,63}; int l... : "); for (i = 0;i < l;i++ ){ System.out.print(" " + num[i
java programming problem - Java Beginners
java programming problem  we are given a number ,num. ( 0<2 ) we have to represent the number(num) in the form of a,b,c,d such that: num=(a/b)*(c/d) for eg. let num=2, then a=1.5 b=0.75 c=0.4 d=0.4
java
java  how to access input as integer in java?   import... Number: "); int num=input.nextInt(); System.out.println("Entered Number is: "+num
java
java  write a java pgm to illustrate the keywords super,static... class instance of the current class. class Base{ protected int num; public Base(int n){ num = n; System.out.println("parameter constructor of Base class
a java program... - Java Beginners
a java program...  write a program to check that a number...:"); int num = Integer.parseInt(bf.readLine()); int n = num; //use to check at last time int check=0,remainder; while(num > 0){ remainder = num % 10
java - Java Beginners
java  i have to make a programm in java to multiply any number... of mathematical operators. int result=Integer.parseInt(String.valueOf(num)+"00"); // here num is the required Number. Here we are using String concatination
Java Programming - Java Beginners
Java Programming  Write and run a program that accepts a string...{ String st = "100"; int num=Integer.parseInt(st); System.out.println("Number= "+num); } } Thanks
Java Code - Java Beginners
(" " + num[i]); } } } For more example on Java visit to : http...Java Code  Code a statement that creates an array of doubles named... static void main(String[] args){ double num[] = {27.2, 33.5,12.8,56.4
a java program - Java Beginners
a java program  well sir, i just wanna ask you something regarding...)); System.out.println( " enter the number : "); int num = Integer.parseInt (br.readLine()); if (num %2==0) continue; System.out.println("this number is even :" +num
Java Program - Java Beginners
Java Program  Write a program to find the Factorial of a number using... FactorialUsingRecursion { public int findFactorial(int num) { int f; if (num < 0){ System.out.println("Error"); } if ( num ==1) return 1; f
flowchart - Java Beginners
]=0; fib[1]=1; int num; int i; num=Integer.parseInt(JOptionPane.showInputDialog("Enter Number:")); if(num>1) { for(i=2;i<=num;i++) { fib[i.../java/example/java/swing/ http://www.roseindia.net/tutorials/swt/flowchart.shtml
Java Coding - Java Beginners
Java Coding  How do I code the following: Code a while loop... = 0; int num=0; while(num<100) { count++; num = 5*count; sum = sum + num ; System.out.println(" 5 * " + count + " = "+ num
How to create and use Array in Java?
How to create and use Array in Java?  Hi, How to create and use Array in Java? Write program to construct and use the array. Thanks   Hi, You can initialize the int array in following way: int num[] = new int[10
code - Java Beginners
code  how to get the cube root of a number in java?the simpliest form...[]){ double num = 64.00; System.out.println("Cube root of "+num+" is :"+Math.cbrt(num) ); } } Thanks RoseIndia Team
Perfect Numbers - Java Beginners
+ 2 + 3 Write a java program that finds and prints the three smallest perfect...; for(int num=1;num<500;num++){ for(int i=1;i
Exceptions - Java Beginners
of integers from the command line (-1 to stop). Use Java's Exception handling...); System.out.println("Enter Integer values: "); int num=0; while(num!=-1){ try { num = input.nextInt

Ads