简体   繁体   English

将.txt文件直接放入数组Java

[英]Putting .txt file directly into array java

I am writing a hangman code, and for school I have to use a list containing all Dutch 10 letter words, which are about 80.000 words. 我正在编写一个子手代码,对于学校,我必须使用一个包含所有荷兰语10个字母的单词的列表,这些单词大约为80.000个单词。 I would like to put them in an array, but I don't have the time to do 我想将它们放在一个数组中,但是我没有时间做

String[] wordList;
wordList[1] = AAGJESAPPEL (first word)
wordList[2] = AAIBAARHEID (second word)

etc etc. Is there a way to import these words from the .txt file they are in, and put them directly into an array? 等。有没有办法从它们所在的.txt文件中导入这些单词,并将其直接放入数组中? The words are all on separate lines, and i would like for each word to be a new additon to the array. 单词都在单独的行上,我希望每个单词都成为数组的新成员。 I know there are other posts on this topic, but those are too difficult for me to understand, please help me :) 我知道有关此主题的其他帖子,但是这些帖子对我来说太难理解了,请帮助我:)

During the first cycle you enter to 在第一个周期中,您输入

 if (direction.equals("up") && upcounter < 6) {
       y = y - 1;
       upcounter++;
  }

As y=0 in the beginning, after than block y=-1. 由于开始时y = 0,则之后的块y = -1。

I suggest you to debug your code to understand what is happening 我建议您调试代码以了解发生了什么

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM