How do we actually discard last file from java string and just get the file path directory?
Random Path input by user:
The easiest and most failsafe (read: cross-platform) solution is to create a
File object from the path.
File myFile = new File( "C:/my folder/tree/apple.exe" ); // Now get the path String myDir = myFile.getParent();