文件内容java文件详细信息 [英] File content java files details

查看:108
本文介绍了文件内容java文件详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个代码,告诉我文件夹的详细信息,但无法获取文件夹中的内容的详细信息,我可以任何人帮助plss。



代码我有这个



I have a code that tell me the details of folder but cant get the details of content in the folder i have can anyone help plss.

The code i have is this

public static void main(String[] args) throws Exception {
    Path path = FileSystems.getDefault().getPath("C:\\Users\\varinder\\Desktop");
    displayFileAttributes(path);
  }

  private static void displayFileAttributes(Path path) throws Exception {
    String format = "Exists: %s %n" + "notExists: %s %n"+ "Readable: %s %n"+ "Writable: %s %n"+ "Size: %s %n";

    System.out.printf(format, Files.exists(path, LinkOption.NOFOLLOW_LINKS),
        Files.notExists(path, LinkOption.NOFOLLOW_LINKS),
        Files.isReadable(path),Files.isWritable(path),
        Files.size(path));
  }
}

推荐答案

我不会说流利的Java,所以我不会发布一些Java代码,而是一些伪代码。



在displayFileAttributes方法的末尾,你必须迭代当前路径的每个元素,并递归调用displayFileAttributes for它们:

I'm not fluent in Java, so I won't post some Java code, but rather some pseudo-code.

At the end of your displayFileAttributes method, you have to iterate over each element of the current path, and recursively call displayFileAttributes for them:
for each (FileSystemElement element in path.getFileSystemElements()) {
   displayFileAttributes(element);
}





希望这有帮助。



Hope this helps.


这个问题的最佳答案应该是给你一个清晰的想法: http://stackoverflow.com/questions/1844688/read-所有文件夹在文件夹中 [ ^ ]。



-SA
The top answer to this question should give you a clear idea: http://stackoverflow.com/questions/1844688/read-all-files-in-a-folder[^].

—SA


这篇关于文件内容java文件详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆