Cross-platform way to examine the contained file folder


  is there a function in java to open the containing file folder on any platform. I can execute this on Windows by running

Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("explorer /select,c:\\sampleFile.txt");

You can open the file (if the Desktop api is supported) on any platform using java.awt.Desktop.getDesktop().open(file). Is there something similar to call the file manager?

Thank.

+3
source share
1 answer

What happens if you call getDesktop (). open (file.getParentFile ())?

+6
source

Source: https://habr.com/ru/post/1772012/


All Articles