?
Solved

count characters in a file

Posted on 2002-04-14
3
Medium Priority
?
185 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
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 100 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

840 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