+
+ /**
+ * Let me know when the output indicates the specified message.
+ *
+ * @param msg
+ * @param r
+ */
+ private void debugOut(String msg, Runnable r)
+ {
+ int len = msg.length();
+ int c0 = msg.charAt(0);
+ boolean[] recording = new boolean[1];
+ System.setOut(new PrintStream(new OutputStream()
+ {
+
+ StringBuffer out = new StringBuffer();
+
+ @Override
+ public void write(int b) throws IOException
+ {
+
+ if (recording[0])
+ {
+ out.append((char) b);
+ if (out.length() == len)
+ {
+ if (out.toString().equals(msg))
+ {
+ r.run();
+ }
+ recording[0] = false;
+ out.setLength(0);
+ }
+ }
+ else if (b == c0)
+ {
+ out.append((char) b);
+ recording[0] = true;
+ }
+ }
+
+ }));
+
+ // TODO Auto-generated method stub
+
+ }
+
+ private static void flushEvents()
+ {
+ ((sun.awt.SunToolkit) Toolkit.getDefaultToolkit()).flushPendingEvents();
+ }