fork(11) download
  1. import java.nio.file.*;
  2.  
  3. class Ideone {
  4. public static void main(String[] args) {
  5. Path path = Paths.get("/some/foo");
  6. System.out.println("path = " + path);
  7. System.out.println("getFileName() = " + path.getFileName());
  8.  
  9. path = path.resolveSibling(path.getFileName() + ".bar");
  10. System.out.println("path = " + path);
  11. }
  12. }
Success #stdin #stdout 0.09s 28264KB
stdin
Standard input is empty
stdout
path = /some/foo
getFileName() = foo
path = /some/foo.bar