I’m looking to either clean up or make more efficient my program, but I’m not sure how. Here’s what my program does:
I take a webpage, turn it into a string, scan it for a keyword, if I don’t find the keyword, I rebuild the string taking care of any possible page edits (effectively refreshing the webpage), and this program goes on forever. If ever the webpage is not available, it just runs the main program again. It’s a monitoring program.
I can imagine this constant string building to consume memory over time, similar to a memory leak. Anyway to fix this cleverly?
Also, can I print a message to the windows command prompt in a java program?
As long as your code releases references to the objects that it holds, then the garbage collector will free up the memory for you. You don’t have to do anything else.
To print to the console, its as simple as this.
or