Programming

So I got a JFrame app the other day for a plugin on a program. I found out how to change variable values in a text file without a recompile of the java class. Here it is (I did not include the preliminary java declarations/import classes, but they must also be included as usual).




The var declare portion of app.java file

Static int varName = Integer.parseInt(readData("config.txt", "WindowWidth"));



The config.txt file

WindowWidth = 205


After compiling the java file (cmd "javac app.java"), you will be able to change the initial value of varName by changing the value of WindowWidth in the text file. It works great!!

No comments:

Post a Comment

Comment loud, comment often. But comment on the content!

All comments are filtered through to my email, so your spam will never make it. Unless, of course, you wanted to try injection attacks into my email, which would probably not happen since Blogger just tells me that a comment is awaiting moderation and doesn't bother to tell me what it says. I trust Blogger like that..