Java examples for File Path IO:Path
Removing redundancies by normalizing a path
import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void main(String[] args) { Path path = Paths.get("/home/docs/../music/SpaceMachine A.mp3"); System.out.println("Absolute path: " + path.toAbsolutePath()); System.out.println("URI: " + path.toUri()); System.out.println("Normalized Path: " + path.normalize()); System.out.println("Normalized URI: " + path.normalize().toUri()); System.out.println();// w w w . j a v a2 s.c o m path = Paths.get("/home/./music/ Robot Brain A.mp3"); System.out.println("Absolute path: " + path.toAbsolutePath()); System.out.println("URI: " + path.toUri()); System.out.println("Normalized Path: " + path.normalize()); System.out.println("Normalized URI: " + path.normalize().toUri()); } }