-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFile2.java
More file actions
36 lines (35 loc) · 745 Bytes
/
File2.java
File metadata and controls
36 lines (35 loc) · 745 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
36
import java.io.*;
public class File2
{
public static void main(String arg[])
{
try
{
FileInputStream f1=new FileInputStream("abc1.txt");
int c,d=0,ch=0,sp=0,li=0,sy=0;
while((c=f1.read())!=-1)
{
if(Character.isLetter(c))
ch++;
else if(Character.isDigit(c))
d++;
else if(c==' ')
sp++;
else if(c=='\n')
li++;
else
sy++;
}
System.out.println("character count="+ch);
System.out.println("digit count="+d);
System.out.println("symbol counnt="+sy);
System.out.println("space counnt="+sp);
System.out.println("Line counnt="+li);
f1.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}