Hello everyone, I'm hoping someone here will be able to help me since I can't seem to find any information on a past issue like this.
What I am doing is reading a plain-text configuration file line by line for a project I am working on. But at the moment I don't seem to be able to even get Scanner to read the file.
Configuration file in question is attached (not allowed to link to pastebin sorry).
Distilled test code:
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class TestScannerMain { public static void main(String[] args) { try (Scanner scan = new Scanner(new File("Pony.txt"))) { while (scan.hasNextLine()) { System.out.println(scan.nextLine()); } } catch (FileNotFoundException e) { e.printStackTrace(); } System.out.println("Done"); } }
I have tried -
- Recreating the file
- Using a different file (Using a file I have created by hand seems to work but I need to use the existing files.)
- Changing the extension (It originally was an .ini file but it is just plaintext with a different extension)
At this point I'm thinking it has to do with how the textfile is encoded but I have no idea what the arguments for the Scanner constructor using them for, and I can't seem to find any documentation with this information. Any ideas?
And thanks in advance for any help!