Hi, im trying to get this to read the registry by reading the contents of a folder, turning it in to an array then displaying the contents. When i compile it works fine with no errors, however when i run it once compiled, it give me the errorI've tried putting throw IOException in to, which compiles fine but still gives me the same error message.Exception in thread "main" java.lang.NullPointerException
at USBDevices.main(USBDevices.java:19)
Can anyone help me with this?
Thanks
import java.io.*; import java.util.*; public class USBDevices { public static void main(String[] args) { // This retrieves the files from the registry and inserting it in to an array called file java.io.File listroot = new java.io.File("\"HKLM\\SYSTEM\\CurrentControlSet\\Enum\\USBSTOR\""); java.io.File[] files = listroot.listFiles(); System.out.println("USB Registry Entries:"); // This opens the array called and displays the results for (java.io.File file : files) { if (file.isDirectory()) continue; System.out.println(file.getPath()); } } }