This is part of larger graphing program (JavaPlot specifically). In a nut shell, I would try to graph something; the graph would appear at
out.write(comms);
but then close once it hit
out.close()
I know you need to close OutputStreamWriter, so instead of removing that line, I created a Scanner that waits until the user presses 'Q' and then the program continues as normal, closes the graph, the OutputStreamWriter, and the Scanner
OutputStreamWriter out = new OutputStreamWriter(proc.getOutputStream());
out.write(comms);
out.flush();
//added from here
//waiting until input is given
Scanner timeKiller = new Scanner(System.in);
String check = timeKiller.nextLine();
if(check != "q"){
check = timeKiller.nextLine(); //<---waiting here.
}
timeKiller.close();
//to here
out.close();
Is what I'm doing dangerous? If someone closes the graph by closing the window, this won't kill the program, correct? This won't cause a memory leak (right?) but if the process is still running and they run this program several times, it will eventually start to be an issue. How can I fix this? Just off the top of my head, maybe add a listener to the window that breaks the loop if the window is closed? Or am I mistaken and this is isn't an issue at all?