The Scanner class has a Scanner(InputStream) constructor Scanner(InputStream) ; therefore, you can still use this class to read data, as you did before.
All you have to do is read the file from the Jar, you can do it like this:
InputStream is = getClass().getResourceAsStream("champdata.txt"); Scanner read = new Scanner(is); read.useDelimiter("%");
If a file called champdata.txt is located at the root of your jar file (which is just a zip file, you can use any unzipper to check where the file is located).
Now, if you want to have the same functionality when developing in your IDE, put the file in your source directory so that when the project is built, it will be placed in your classes folder. Thus, the file can be loaded as described above using getResourceAsStream()
source share