I can't tell how deeply I hate JAVA, however this code works.