For example, the content of a file is:
black=white
bad=good
easy=hard
So, I want to store in a map this words as key and value (ex: {black=white, bad=good} ). And my problem is when I read string I have to skip a char '=' which disappears key and value. How to make this?
In code below I make a code which read key and value from file, but this code works just when between words is SPACE, but I have to be '='.
System.out.println("File name:");
String pathToFile = in.nextLine();
File cardFile = new File(pathToFile);
try(Scanner scanner = new Scanner(cardFile)){
while(scanner.hasNext()) {
key = scanner.next();
value = scanner.next();
flashCards.put(key, value);
}
}catch (FileNotFoundException e){
System.out.println("No file found: " + pathToFile);
}