package java_homework;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.Arrays;import java.util.regex.Matcher;import java.util.regex.Pattern;public class testBeta { public static void main(String[] args) throws IOException { File fleInput=new File("D:\\zed.txt"); FileInputStream fis=new FileInputStream(fleInput); InputStreamReader fsr=new InputStreamReader(fis); BufferedReader br=new BufferedReader(fsr); int intAlpha,intNum,intOther,intChinese; intAlpha=intNum=intOther=intChinese=0; int intChar=br.read(); while (intChar!=-1){ if ((intChar>=0x41 && intChar<=0x5A) || (intChar>=0x61&& intChar<=0x7A)){ intAlpha++; }else if (intChar>=0x30 && intChar<=0x39){ intNum++; }else if (intChar>=0 && intChar<=127) { intOther++; }else{ intChinese++; } intChar=br.read(); } fis.close(); System.out.println("Alpha count=" + intAlpha); System.out.println("Number count=" + intNum); System.out.println("Other count=" + intOther); System.out.println("Chinese count=" + intChinese); } }
添加回答
举报
0/150
提交
取消