fork download
  1. import java.nio.file.Path;
  2. import java.nio.file.Paths;
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) {
  7.  
  8. final Path wholePath = Paths.get("/usr/animals/data/donkey/data.txt");
  9. final Path find = Paths.get("/usr/animals/data/donkey");
  10. final Path replace = Paths.get("/usr/animals/data/sym4");
  11.  
  12. Path expected = Paths.get("/usr/animals/data/sym4/data.txt"); // how to get this?
  13.  
  14. Path path = Paths.get(wholePath.toString().replace(find.toString(), replace.toString()));
  15.  
  16. System.out.println(expected.equals(path));
  17. }
  18. }
  19.  
Success #stdin #stdout 0.06s 32604KB
stdin
Standard input is empty
stdout
true