Solved

count characters in a file

Posted on 2002-04-14
3
181 Views
Last Modified: 2010-08-05
What is code for counting the number of characters in a file?
I've written out a file, now i want the number of characters in it.
0
Comment
Question by:xoxomos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6941088
I don't think multiple postings is actually allowed.
0
 
LVL 1

Accepted Solution

by:
naveeth earned 25 total points
ID: 6941097
import java.io.*;

public class FileTest {
  public static void main(String[] args) {
      try {
         File f = new File("myFile.txt");
          System.out.println("the no of char in the file :"+f.length());
}catch(Exception e)
{
System.out.println("exception"+e);
}
}
}



0
 

Author Comment

by:xoxomos
ID: 6941182
Thanks, thought i did that but..... will try again tomorrow.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question