Skip to content
Snippets Groups Projects
Commit 057185d1 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

handle IOException internally for simpler usage

parent 295f1d58
No related branches found
No related tags found
No related merge requests found
...@@ -55,51 +55,46 @@ public class PduListenerSaver ...@@ -55,51 +55,46 @@ public class PduListenerSaver
} }
System.out.println("Beginning pdu save to directory " + outputDirectoryPath); System.out.println("Beginning pdu save to directory " + outputDirectoryPath);
try {
PduRecorder recorder = new PduRecorder(outputDirectoryPath, multicastAddress, port); // assumes save PduRecorder pduRecorder = new PduRecorder(outputDirectoryPath, multicastAddress, port); // assumes save
mystate state = mystate.RUNNING; mystate state = mystate.RUNNING;
Scanner scan = new Scanner(System.in); Scanner scan = new Scanner(System.in);
while (true) while (true) // monitor user input via keyboard
{ {
System.out.println("Type p/enter to pause, r/enter to resume, q/enter to quit"); System.out.println("Type p/enter to pause, r/enter to resume, q/enter to quit");
String line = scan.nextLine(); String line = scan.nextLine();
if (line.equalsIgnoreCase("p") && state == mystate.RUNNING) if (line.equalsIgnoreCase("p") && state == mystate.RUNNING)
{ {
recorder.stopPause(); pduRecorder.stopPause();
state = mystate.PAUSED; state = mystate.PAUSED;
System.out.println("... state is now PAUSED"); System.out.println("... state is now PAUSED");
} }
else if (line.equalsIgnoreCase("p")) else if (line.equalsIgnoreCase("p"))
{ {
recorder.stopPause(); pduRecorder.stopPause();
state = mystate.PAUSED; state = mystate.PAUSED;
System.out.println("... state is still PAUSED"); System.out.println("... state is still PAUSED");
} }
else if (line.equalsIgnoreCase("r") && state == mystate.PAUSED) else if (line.equalsIgnoreCase("r") && state == mystate.PAUSED)
{ {
recorder.startResume(); pduRecorder.startResume();
state = mystate.RUNNING; state = mystate.RUNNING;
System.out.println("... state is now RUNNING"); System.out.println("... state is now RUNNING");
} }
else if (line.equalsIgnoreCase("r")) else if (line.equalsIgnoreCase("r"))
{ {
recorder.startResume(); pduRecorder.startResume();
state = mystate.RUNNING; state = mystate.RUNNING;
System.out.println("... state is still RUNNING"); System.out.println("... state is still RUNNING");
} }
else if (line.equalsIgnoreCase("q")) else if (line.equalsIgnoreCase("q"))
{ {
recorder.end(); pduRecorder.end();
System.out.println("... QUIT"); System.out.println("... QUIT");
break; break;
} }
}
System.out.println("Ending pdu save to log file " + recorder.getLogFilePath());
}
catch (IOException ex)
{
System.err.println("Exception: " + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
} }
System.out.println("Ending pdu save to log file " + pduRecorder.getLogFilePath());
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment