0

Hello everybody I have a problem to determine the difference between two paths.

Let's say there are two pathes main.cache and another/system.cache

I would like to get the folder difference between these two paths. For example for these two file it would be another/.

I do it because I have list of files (per line) in another/system.cache relative to the system.cache file. For example

../images/a.jpg
../images/b.jpg
../images/c.jpg

I need to get the paths relative to the main.cache file so I would just join another/../images/a.jpg (and then normalize it to images/a.jpg)

I was playing with java.nio and Pathes and trying to solve it with relativize or resolve but with no success. For example relativize consider main.cache as folder and returns ../another/system.cache which is nonsense.

Is there any simple solution I missed? Thanks

kuncajs
  • 1,096
  • 1
  • 9
  • 20
  • -1 a path must not exists, name it folder or relative folder. main.chache is not a complete path and not a path to an existing folder, it is a relative-path or a folder-name or a file-name. another/system.cache is a relative-file or a relative-folder. Please change the question. – Grim Mar 14 '13 at 12:34
  • As I said: I tried relativize which consider file as a folder unfortunately, I tried playing with resolve which returns complete nonsenses for me. Also I found this solution: http://stackoverflow.com/questions/204784/how-to-construct-a-relative-path-in-java-from-two-absolute-paths-or-urls which will probably work, but my question is whether in Java 7 and NIO is not a more robust and modern solution. – kuncajs Mar 14 '13 at 12:36
  • @PeterRader I don't get what is wrong? They are all relative paths as written in the body of the question. Also the class in Java7 is called `java.nio.Path` which does almost what I need. – kuncajs Mar 14 '13 at 12:58

0 Answers0