Java – Convert File to Path

This article shows how to convert a File to a Path in Java. java.io.File => java.nio.file.Path // Convert File to Path File file = new File("/home/mkyong/test/file.txt"); Path path = file.toPath(); java.nio.file.Path => java.io.File // Convert Path to File Path path = Paths.get("/home/mkyong/test/file.txt"); File file = path.toFile(); 1. Convert File to Path In Java, we can …

Read more