In java, I have used File.listRoots() method to get root file list. It works fine for windows but does not work for linux. I want it to work for all operation systems, windows, linux, mac os, etc. How can I do it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There only is one file system root on *NIX systems like Linux, which is called
/. There might be different partitions, mounted at different locations in the file system tree, but there only ever is one tree, and/is its root. Everything else is reachable from there.If you want to list partitions, that would be a different question, and likely one which has no portable solution, as partitions aren’t a portable concept either. For example Solaris does weird stuff in that area.