Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -4,23 +4,23 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
|
||||
public class LetterFreq {
|
||||
public static int[] countLetters(String filename) throws IOException{
|
||||
int[] freqs = new int[26];
|
||||
BufferedReader in = new BufferedReader(new FileReader(filename));
|
||||
String line;
|
||||
while((line = in.readLine()) != null){
|
||||
line = line.toUpperCase();
|
||||
for(char ch:line.toCharArray()){
|
||||
if(Character.isLetter(ch)){
|
||||
freqs[ch - 'A']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
return freqs;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException{
|
||||
System.out.println(Arrays.toString(countLetters("filename.txt")));
|
||||
}
|
||||
public static int[] countLetters(String filename) throws IOException{
|
||||
int[] freqs = new int[26];
|
||||
BufferedReader in = new BufferedReader(new FileReader(filename));
|
||||
String line;
|
||||
while((line = in.readLine()) != null){
|
||||
line = line.toUpperCase();
|
||||
for(char ch:line.toCharArray()){
|
||||
if(Character.isLetter(ch)){
|
||||
freqs[ch - 'A']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
return freqs;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException{
|
||||
System.out.println(Arrays.toString(countLetters("filename.txt")));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue