1

I have two File objects:

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

Now I would like to subtract file 1 from file 2 so that I get directory/file.txt.
I don't want to use String.substring() since file paths may differ from input.

flavio.donze
  • 7,432
  • 9
  • 58
  • 91

1 Answers1

7

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

bmargulies
  • 97,814
  • 39
  • 186
  • 310