Fix the java JSONFormatter to handle calls to write() correctly

Fix the java JSONFormatter so that it can handle calls to write() after
the call to match() but before the call to result().