Using File:
- import java.io.File;
- public class CountCharInFile {
- public static void main(String[] args) throws Exception {
- File file = new File("D:\\data.txt");
- int fileDataLen = (int) file.length();
- System.out.println(fileDataLen);
- }
- }
Output:
241
data.txt file:
Hi guys !!
This is Ishaan from India.
and I'm reading the data from a text file line by line using BufferedReader.
Isn't it interesting !! to read the data from a file line by line
irrespective of amount of data that a file is having.
No comments:
Post a Comment