Use python, or some other similar scripting language. The alternative is to write a parser yourself (not simple!). With Jython, you can integrate your Java program with Python.