I'm helping write a mod for Minecraft, and I've decided to try and code in some special capes for our staff, and people who win our contests. I've got it so it downloads the .txt files containing the player UUIDs, which works. I've also got it to display the capes just fine when I force it to.
Keyword... When I force it to. I'm a Java amateur, and I'm completely stuck on actually printing the file to a string. Other solutions I've seen print each line to a string, but that's not what I want. I want to print the ENTIRE file to a string, then set a boolean if it contains something which matches a string variable I have set earlier in the code. Printing the entire file shouldn't be an issue as it's a very small file.
So the reason why I don't want the above because the code I've Googled around for iterates using while statements and such. I'd assume that would be constantly changing the string to the line it's reading, so if I used one of these examples and checked for a matching UUID it'd set the variable to true if it found the matching one, then immediately set it back to false after it goes to the next line, right?
The reason why I made these assumptions, is that at this point it would take a long time to test something and find it isn't working and test again because I cannot use the test environment in Eclipse; for this to work I must compile my mod and log in with my account, since to get the information required with this code I need to log in with my account. The version I'm using is a little old (I am a Beta 1.7.3 player) and doesn't support the login variables. Even though I'm using Beta 1.7.3, our mod properly updates the game's authentication and allows the use of the Mojang API, so if you're wondering why or how I'm even trying to get UUIDs in that version, that is the reason.
The reason why I'm posting here and not a Minecraft forum or something is that while this code is for Minecraft, file checking stuff is a general Java thing, so hopefully, this is the right place. Sorry if this is considered a duplicate of a few other posts that cover file reading but I found my case to be a little different.
Also sorry if anything here is stupidly written, or confusing. I'm exhausted after playing with this all night and failing to do so, and thus my proofreading skills are basically gone.
Basically, all I need is to just set a boolean if a UUID that matches one in the downloaded text file. My goal is to set a boolean for the staff capes file and the contest capes files you can see, using a string variable and .toString().contains(profile.getId().toString()). Thank you in advance for reading this. Here's the code I use to grab and download the files in case you wanted to see it.
InputStream staff;
InputStream contest;
File staffList;
File contestList;
String capeInfo = System.getenv("APPDATA") + "/.minecraft/capeinfo/";
try {
staffList = new File(capeInfo + "staff.txt");
staffList.mkdirs(); staffList.createNewFile();
staff = new URL("https://www.dropbox.com/s/q6f4729i2zu02nz/staff.txt?dl=1").openStream();
Files.copy(staff, Paths.get(capeInfo + "staff.txt"), StandardCopyOption.REPLACE_EXISTING);
contestList = new File(capeInfo + "contest.txt");
contestList.mkdirs(); contestList.createNewFile();
contest = new URL("https://www.dropbox.com/s/kvvkfk6emms3qg5/contest.txt?dl=1").openStream();
Files.copy(contest, Paths.get(capeInfo + "contest.txt"), StandardCopyOption.REPLACE_EXISTING);
} catch (MalformedURLException e) {
e.printStackTrace();
return;
} catch (IOException e) {
e.printStackTrace();
return;
}