Files OCP

java.nio.file.Paths

Most methods. dont throw exceptions

java.nio.file.Files

Many methods that change things throw the checked IOExceptions. But Files.exists() does not (as must return boolean).

java.nio.file.Path

Path instances are immutable ( like strings )

pathinstance.relativize(otherpath)

how to get from one place to another (both must be relative or both absolute else Exception )

normalize()

remove redundant parts of a path

    	Path p = Path.of("/temp/../temp/another_dir/inside_another");
    	
    	Path pAfter = p.normalize();
    	
    	/* pAfter is
    	 
    	/temp/another_dir/inside_another
 
    	 */

 

subpath(indexFrom, indexTo)    excellent (from is inclusive , to is exclusive )