I am trying to put strings into an array which have a space as a delimiter, it works great except for the first string has a space in front and so the first element in the array is "" instead of the first string.
public static String[] loadMessage(String fileName)
throws FileNotFoundException {
String[] s = null;
File f = new File(fileName + ".txt");
Scanner inFile = new Scanner(f);
while (inFile.hasNext()) {
s = inFile.nextLine().split(" ");
}
inFile.close();
return s;
}
Is there any easy solution or do I have to write another Scanner and delimiters and what not.