file - About resolve method of the java.nio.Path -


i thoroughly understand use of resolve(path) , relativize(path). in following snippet though there not clear me:

public filevisitresult previsitdirectory(path dir, basicfileattributes attr) throws ioexception         {          destinationfolder = destinationfolder.resolve(source.relativize(dir));         files.copy(dir, destinationfolder,standardcopyoption.replace_existing);          return filevisitresult.continue;         } 

this snippet has been taken here (previsitdirectory method). have modified changing name of target destinationfolder.

if destinationfolder /home/user/desktop/destination , source , dir (at least first recursive call) /home/user/desktop/tobecopied.

the result of destinationfolder /home/user/desktop/destination. works fine , supercool cannot see why gives outcome since source.relativize(dir); returns ../tobecopied , destinationfolder.resolve(../tobecopied) should return (without normalizing it) /home/user/desktop/destination/../tobecopied hence /home/user/desktop/tobecopied. if case program not work, /tobecopied self copy (if makes sense). happens in somehow system takes relative pattern used in source.relativize(dir) ../tobecopied , read "go 1 step , comeback" not "go 1 step , /tobecopied". why happen though? logically should give /home/user/desktop/destination/../tobecopied instead returns /home/user/desktop/destination. missing? lot in advance!

ps: dir current directory of recursive method previsitdirectory , first call same source itself.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -