fork download
  1. import java.nio.file.*;
  2.  
  3. class Ideone {
  4. public static void main(String[] args) {
  5. Path path = Paths.get("/some/foo.test");
  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.18s 57360KB
stdin
Standard input is empty
stdout
path = /some/foo.test
getFileName() = foo.test
path = /some/foo.test.bar