How to get file creation date in Java
In Java (@since 1.7), we can use the NIO Files.readAttributes to get all the file metadata, including the file creation date. We also can use the same code to get…
Favourite tutorials for developers
In Java (@since 1.7), we can use the NIO Files.readAttributes to get all the file metadata, including the file creation date. We also can use the same code to get…
This article shows how to do file transfer from a remote server to the local system and vice versa, using SSH File Transfer Protocol (SFTP) in Java. This Java example…
This article shows, in Java, how to move a file to another directory in the same file drive or remote server: (1) Files.move – Move file in local system, (2)…
In Java, we can use the NIO Files.move(source, target) to rename or move a file. The Apache FileUtils.moveFile uses a "copy and delete" mechanism to rename or move a file.…
Two Java examples to show you how to list files in a directory: For Java 8, use Files.walk. Before Java 8, create a recursive loop to list all files.
In Java, for NIO Path, we can use path.toAbsolutePath() to get the file path; For legacy IO File, we can use file.getAbsolutePath() to get the file path.For symbolic links or…
In Java, we can use the Java 1.7 FileVisitor or Apache Commons IO FileUtils.copyDirectory to copy a directory, which includes its sub-directories and files. This article shows a few of…
This article shows how to get the file extension of a file in Java. This example shows how to use String#lastIndexOf to get the file extension of a file, and…
This article shows how to Java 8 Files.walk to walk a file tree and stream operation filter to find files that match a specific file extension from a folder and…
In Java, we can use the NIO Files.delete(Path) and Files.deleteIfExists(Path) to delete a file. The Files.delete(Path) deletes a file, returns nothing, or throws an exception if it fails. If the…