1
public void checkfile (String serverName) throws Exception {
    if (serverName == null)
    serverName = "";
    System.out.println("IN Check file method");
    File folder = new File("D:\\MVXOUT412");     //Path on the server
    int count = 0;
    String abc;
    File[] files =  folder.listFiles();
    if (files != null) {
        System.out.println("IN IF method");
        for (int i=0;i<files.length ;i++) {
            count++;
            abc = files[i].getName();
            System.out.println("Number of files: " + count);
            System.out.println("Name of files: " + abc);
        }
    }
}

此代码仅显示服务器上路径/文件夹中的一些文件。其他文件无法查看。登录和注销成功发生。

4

1 回答 1

0
 public void listFilesForFolder(final File folder) {
 for (final File fileEntry : folder.listFiles()) {
     if (fileEntry.isDirectory()) {
        listFilesForFolder(fileEntry);
    } else {
        System.out.println(fileEntry.getName());
    }
}
  }

   final File folder = new File("/home/you/Desktop");
 listFilesForFolder(folder);
于 2013-08-13T08:12:36.180 回答