Java isn’t provides copy file function, So to copy file we must convert file to stream, and create new file from the stream. Example, use FileInputStream to convert file “test.txt” to stream, OutputStream to convert the stream to new file (copy file).
In Java, use renameTo() method from File class to rename file. Example
In java, you can use listFiles() method in File class to list files with certain extention. In this example, we show you how to use FilenameFilter to list out all files that are end with “.txt” extension in folder “d:\\temp”, and then delete them.
1. Use the listFiles() method provided by the java.io.File class Example1 2. Use the list() method provided by the java.io.File class Example2
How to append a string in an existing file? There is a simple way is use FileWriter class. By default, the constructor FileWriter(filePath) will replace content of file with new content. Additional, the constructor FileWriter(filePath, append) if append = true, new content will be append to at the end of the file. This example shows … Read more
Scanner be born later, so it has more advances than the elder brothers as BufferedReader, Console … because it has the ability to sort the data that users enter from the keyboard. For example, it can read data types such as int, float, double, long, char … Example: Output Demo Create menu with Scanner Demo … Read more