Programming Tips - How can I list the names of all the files that Java has open?

Date: 2015jul14 Language: Java OS: Linux Q. How can I list the names of all the files that Java has open? A. Assuming you only have one instance of Java (eg Jetty) this script does it:
#!/bin/sh PID=`pidof /usr/bin/java` lsof -p $PID