Search code examples
niojava-7

Get file/directory size using Java 7 new IO


How can I get the size of a file or directory using the new NIO in java 7?


Solution

  • Use Files.size(Path) to get the size of a file.

    For the size of a directory (meaning the size of all files contained in it), you still need to recurse manually, as far as I know.