에서 Python나는 두 개의 경로를 가입 할 수 있습니다os.path.join 같이 .
os.path.join("foo", "bar") # => "foo/bar"
나는이 경우 걱정하지 않고, 자바에서 동일한을 실현하려 노력하고 OS있다 Unix, Solaris또는 Windows:
public static void main(String[] args) {
Path currentRelativePath = Paths.get("");
String current_dir = currentRelativePath.toAbsolutePath().toString();
String filename = "data/foo.txt";
Path filepath = currentRelativePath.resolve(filename);
// "data/foo.txt"
System.out.println(filepath);
}
나는이 기다리고 있었다 Path.resolve( )나의 현재 디렉토리에 가입 할 /home/user/test로 data/foo.txt만들기 /home/user/test/data/foo.txt. 내가 뭘 잘못하고 있니?
new File(parent, child)
filepath.toString()