Scanner in = new Scanner(new File("path_to_file.txt"));
String var = in.next();
var = var.trim();
in.close();
Not the most efficient way, but one of the simplest.
0
solved How can I read a single word from a txt file and make it a variable in my code? [closed]