79381295

Date: 2025-01-23 13:41:36
Score: 2
Natty:
Report link

I found a solution that worked! Here's my current code. I've forgone the conversion from an ArrayList to an Array, and am now working with an ArrayList on the other side:

package hangman;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class GetHangmanWords {
    public static ArrayList<String> get() throws IOException {
        InputStream in = GetHangmanWords.class.getResourceAsStream("words.txt");
        
        InputStreamReader inReader = new InputStreamReader(in);
        BufferedReader reader = new BufferedReader(inReader);
        
        ArrayList<String> lines = new ArrayList<String>();
        while (lines.contains(null) != true) {
            lines.add(reader.readLine());
        }
        
        lines.removeLast();
    
        return lines;
    }

}

Thanks especially to @DuncG for getting me on the right path!

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @DuncG
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Dante_05