title: How to get the relative file path difference in Java 7
body: <p>Hello everybody I have a problem to determine the difference between two paths.</p>
  
  <p>Let's say there are two pathes <code>main.cache</code> and <code>another/system.cache</code></p>
  
  <p>I would like to get the folder difference between these two paths. For example for these two file it would be <code>another/</code>.</p>
  
  <p>I do it because I have list of files (per line) in <code>another/system.cache</code> relative to the <code>system.cache</code> file.
  For example</p>
  
  <pre><code>../images/a.jpg
  ../images/b.jpg
  ../images/c.jpg
  </code></pre>
  
  <p>I need to get the paths relative to the main.cache file so I would just join
  <code>another/../images/a.jpg</code> (and then normalize it to <code>images/a.jpg</code>)</p>
  
  <p>I was playing with <code>java.nio</code> and Pathes and trying to solve it with <code>relativize</code> or <code>resolve</code> but with no success.
  For example <code>relativize</code> consider <code>main.cache</code> as folder and returns <code>../another/system.cache</code> which is nonsense.</p>
  
  <p>Is there any simple solution I missed?
  Thanks</p>