Java Program for counting Lines words and Characters in a File || Java Lab Programs || Java Tutorial

Published: 04 March 2022
on channel: Join To Learn
8,654
155

Java Program for counting Lines words and Characters in a File || Java Lab Programs || Java Tutorial

import java.io.*;
class CountingLWC
{
public static void main(String args[]) throws FileNotFoundException,IOException
{
int l=0,w=0,c=0;

BufferedReader br = new BufferedReader(new FileReader("INPUT.txt"));

String currLine = br.readLine();

while( currLine != null )
{
l++;

String words[] = currLine.split(" ");
w = w + words.length;

for(String word : words)
c = c + word.length();
c = c + (words.length - 1);


currLine = br.readLine();
}
System.out.println("No of Lines: " + l);
System.out.println("No of words: " + w);
System.out.println("No of Characters: " + c);
}
}


On this page of the site you can watch the video online Java Program for counting Lines words and Characters in a File || Java Lab Programs || Java Tutorial with a duration of hours minute second in good quality, which was uploaded by the user Join To Learn 04 March 2022, share the link with friends and acquaintances, this video has already been watched 8,654 times on youtube and it was liked by 155 viewers. Enjoy your viewing!