展开全部
简单写下,思62616964757a686964616fe4b893e5b19e31333332616338路大概是将文件流里的读到字节数组中,然后在通过字符串将其转化成字符数组:import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
public class Test{
static int totalCount(String fileName, char ch) throws Exception{
int count = 0;
InputStream inStream = new FileInputStream(new File(fileName));
byte[] buf = new byte[inStream.available()];
inStream.read(buf);
String str = new String(buf);
char[] charArray = str.toCharArray();
for(char c : charArray){
if(c == ch){
count ++;
}
}
inStream.close();
return count;
}
public static void main(String[] args) throws Exception {
System.out.println("D://t.txt : " + totalCount("D://t.txt",'a'));
}
}