私はtxtファイルからコンコーダンスを印刷しようとしています.スキャナを使用して以下のファイルを読み込んでいます.単語を配列リストに入れるのに問題があるようです.
public class Concordance
{
public static void main (String[]args) throws IOException
{
TreeMap <String, ArrayList<Integer>> concordance = new TreeMap <String, ArrayList<Integer>>();
File myfile = new File ("Caesar.txt");
Scanner scan = new Scanner(myfile);
ArrayList <Integer > integer = new ArrayList <Integer>();
for (int i = 0; i < scan.nextLine().length(); i++)
{
String key = scan.nextLine().toLowerCase();
if (scan.nextLine().length(i) > 1)
{
if (concordance.get(key) == null) {
concordance.put(key, 1))
} else {
ArrayList<Integer> value = concordance.get(key).indexOf(integer);
value++;
concordance.put(key, value);
}
}
}
System.out.println(concordance);
}
}