I have a requirement in my project to display only hard disk letter (C:\ or D:\) even when the user selects the directory/files inside the disk.
This need to work on both Windows and MAC OS. Is there a way to achieve this in Java?
E.g. If the user selected D:\Test\Test1 then we need to get only D:\
You could also take the first three characters from the absolute string path and not bother with the recursive code. And it is still not going to work on any OS besides Windows variants that work with drive letters.