public static void listardirectorio() {
        File directorio = new File("C:\\ ");
        if ((directorio.exists()) && (directorio.isDirectory())) {
          //  String[] lista = directorio.list();
           // for (int i = 0; i < lista.length; i++) {
            for (String subdir : directorio.list()){
                //System.out.println(lista[i]);
                System.out.println(subdir);
            }
        } else {
            System.out.println("El directorio no existe.");
        }
    }