Solved

count characters in a file

Posted on 2002-04-14
3
175 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
Comment Utility
I don't think multiple postings is actually allowed.
0
 
LVL 1

Accepted Solution

by:
naveeth earned 25 total points
Comment Utility
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
Comment Utility
Thanks, thought i did that but..... will try again tomorrow.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now