In addition to the question above, I would suggest that you use the ability to format EXPLAIN plans as XML in PostgreSQL 9.0 and later.
EXPLAIN (parse, format xml) SELECT ...
This will give you an explanation with which you can easily work in Java by manipulating it as XML.
source share