flavio.donze flavio.donze - 1 year ago 65
Java Question

Best way to get a sub-path of a file

I have two


  1. C:/basepath/

  2. C:/basepath/directory/file.txt

Now I would like to subtract file 1 from file 2 so that I get

I don't want to use
since file paths may differ from input.

Answer Source

Use the features of java.nio.file.Path. You are looking to 'relativize'.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download