• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

count characters in a file

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
xoxomos
Asked:
xoxomos
1 Solution
 
objectsCommented:
I don't think multiple postings is actually allowed.
0
 
naveethCommented:
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
 
xoxomosAuthor Commented:
Thanks, thought i did that but..... will try again tomorrow.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now