-1
私がしようとしているのは、英語の単語が500,000語含まれているテキストファイルから読み込み、それをパフォーマンス目的のためにHashSetに格納することです。そして、次に、5文字の単語や6文字の単語など、修飾された要素を含むHashSetを返したいと思います。HashSetを反復処理し、修飾された要素でセットを返す方法は?
これは私のコードです。 私はあなたのソリューションに感謝します!
private static HashSet<String> readPuzzleFile(int wordLength) {
HashSet<String> unProcessedPuzzle = new HashSet<String>();
try (Scanner file = new Scanner(new File(PATHTOPUZZLE))) {
while (file.hasNextLine()) {
unProcessedPuzzle.add(file.nextLine());
}
} catch (FileNotFoundException e) {
System.out.println("No Puzzle File Found!");
return null;
}
HashSet<String> puzzle = new HashSet<String>();
Iterator iterator = unProcessedPuzzle.iterator();
for (String word : unProcessedPuzzle){
puzzle.addAll(word);
}
}
そして、あなたの問題や、あなたの質問は何ですか? – IQV
@IQVちょうどそれを行う方法、申し訳ありません最初の質問にそれを入れて忘れてしまった。 –
何をするには? – shmosel