Is there a method to combine routes in Java?

Asked 1 years ago, Updated 1 years ago, 99 views

Is there a method to combine routes in Java? For example,

// to output a/b
System.out.println(path_join("a","b"));
// A/b is output.  
System.out.println(path_join("a","/b");

Like this.

file java path

2022-09-21 17:09

1 Answers

I think you can just use the creator of the file.

public static String combine (String path1, String path2)
{
    File file1 = new File(path1);
    File file2 = new File(file1, path2);
    return file2.getPath();
}

Like this


2022-09-21 17:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.