How to rename or move a file in Java
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.…
Favourite tutorials for developers
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.…
This article shows four ways to copy a file in Java: (1) Files.copy (NIO), (2) Apache Commons IO, (3) Guava, (4) Plain Java. In Java 7+, the NIO Files.copy is…
This article shows a few ways to convert an java.io.InputStream to a String. We will examine a few ways: using ByteArrayOutputStream, using InputStream#readAllBytes (Java 9), using InputStreamReader + StringBuilder, InputStreamReader…