count characters in a file

Posted on 2002-04-14
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.
Question by:xoxomos
LVL 92

Expert Comment

ID: 6941088
I don't think multiple postings is actually allowed.

Accepted Solution

naveeth earned 25 total points
ID: 6941097

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)


Author Comment

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

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet  URL Rewriting 1 42
difference of if loops 23 62
pagenation logic how it is working in my code 1 56
ejb entity bean example 2 17
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
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 …

828 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