How to get file last modified date in Java
In Java, we can use Files.readAttributes() to get the file metadata or attribute, and then lastModifiedTime() to display the last modified date of a file. For legacy IO, we can…
Favourite tutorials for developers
In Java, we can use Files.readAttributes() to get the file metadata or attribute, and then lastModifiedTime() to display the last modified date of a file. For legacy IO, we can…
In Java, we can use DateTimeFormatter to convert the FileTime to other custom date formats.
In Java, we can use the NIO Files.setLastModifiedTime(path, FileTime) to update the last modified date or time of a file. For legacy IO java.io.File, we can use File.setLastModified() to update…
The Files.find API is available since Java 8. It searches or finds files from a file tree quickly. Examples: Find files by filename, Find files by file size, Find files…
In Java, we can use the static or non-static ways to get the path of a running JAR file. We should use toURI() to avoid encoding the special characters in…
The Files.walk API is available since Java 8; it helps to walk a file tree at a given starting path. Examples: list all files, list all folders or directories, find…
This article focus on a few of the commonly used methods to read a file in Java. 1 - Files.lines, return a Stream (Java 8), 2 - Files.readString, returns a…
In Java, we can use getResourceAsStream or getResource to read a file or multiple files from a resources folder or root of the classpath. The getResourceAsStream method returns an InputStream.…
In Java, there are many ways to create and write to a file: using Files.newBufferedWriter (Java 8), using Files.write (Java 7), using PrintWriter, using File.createNewFile
In this article, we will show you how to use java.io.BufferedReader to read content from a file: using Files.newBufferedReader (Java 8), using classic BufferedReader with JDK 1.7 try-with-resources to auto…