forked from Ashish8104/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCount.java
More file actions
28 lines (22 loc) · 676 Bytes
/
Count.java
File metadata and controls
28 lines (22 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.io.*;
class Count{
public static void main(String args[]) throws IOException{
int c=0,w=1,l=0;
BufferedReader br1 = new BufferedReader(new FileReader("f2.txt"));
BufferedReader br2 = new BufferedReader(new FileReader("f2.txt"));
BufferedReader br3 = new BufferedReader(new FileReader("f2.txt"));
while(br1.read() != -1)
c++;
int x = br2.read();
while(x != -1){
if((char)x == ' ' || (char)x == '\n')
w++;
x = br2.read();
}
while(br3.readLine() != null)
l++;
System.out.println("Number of chracters: " + c);
System.out.println("Number of words: " + w);
System.out.println("Number of lines: " + l);
}
}