public static String join ( Path path1 , Path path2 ) { if ( path2 . toString ( ) . isEmpty ( ) ) { return "" ; } if ( ! path1 . isAbsolute ( ) ) { path1 = Paths . get ( "." , path1 . toString ( ) ) ; } if ( ! path2 . isAbsolute ( ) ) { path2 = Paths . get ( "." , path2 . toString ( ) ) ; } Path result = path1 . resolve ( path2 ) . normalize ( ) ; if ( ! result . isAbsolute ( ) ) { result = Paths . get ( "." , result . toString ( ) ) ; } return result . toString ( ) ; }
Join two paths