导入大量单词,我需要创建能识别文件中每个单词的代码。我正在使用分隔符来识别每个单词的分隔,但我收到一个压缩错误,指出未使用linenumber和分隔符的值。我需要做些什么才能让程序读取该文件并分离该文件中的每个单词?识别文件中的每个单词
public class ASCIIPrime {
public final static String LOC = "C:\\english1.txt";
@SuppressWarnings("null")
public static void main(String[] args) throws IOException {
//import list of words
@SuppressWarnings("resource")
BufferedReader File = new BufferedReader(new FileReader(LOC));
//Create a temporary ArrayList to store data
ArrayList<String> temp = new ArrayList<String>();
//Find number of lines in txt file
String line;
while ((line = File.readLine()) != null)
{
temp.add(line);
}
//Identify each word in file
int lineNumber = 0;
lineNumber++;
String delimiter = "\t";
//assess each character in the word to determine the ascii value
int total = 0;
for (int i=0; i < ((String) line).length(); i++)
{
char c = ((String) line).charAt(i);
total += c;
}
System.out.println ("The total value of " + line + " is " + total);
}
}
...这是所有的代码? – Pimgd
@Pimgd编辑添加我的所有代码 – mrsw
格式化它,因此它对我来说是可读的... – Pimgd