-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCount.java
More file actions
35 lines (25 loc) · 779 Bytes
/
Count.java
File metadata and controls
35 lines (25 loc) · 779 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
29
30
31
32
33
34
35
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++;
while(br3.readLine() = 0a)
l++;
System.out.println("Number of chracters: " + c);
System.out.println("Number of words: " + w);
System.out.println("Number of lines: " + l);
System.out.println("Number of chracters: " + c,w);
}
}