Python os.path.dirname and os.path.sep in Java?

Issue

Python has os.path.dirname and os.path.sep. How can I get these values in Java?

Solution

Did a bit of googling on what os.path.dirname and os.path.sep actually are

os.path.dirname(path) would be filePath.split(System.getProperty("path.separator"))[0]

os.path.sep would be System.getProperty("file.separator")

Answered By – phflack

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published