I am trying to read from a text file using JFileChooser and i need the reader.ReadLine to stop reading after a space has been found. So i am looking to regex to help me solve this issue. The text file i am trying to read from has just one word and after that a few numbers that have hints for guessing that word associated with them
You could simply use the already generated Array: String[] splittt = lines.split(" ") and then use elements 1 to (length-1) in a for loop with Integer.parseInt to generate an integer (or null if it aint one) from the rest of the line
edit: You might want to use an ArrayList<ArrayList<Integer>> for that. or even better a Hashmap, where you use the word as a key (if you can guarantee that the words arr all unique) or give them all an unique identifier (hence for simplicity I would use the current line number or something like that)