Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save asdf913/96b0f4738b9669be2297aa3f43624cad to your computer and use it in GitHub Desktop.
Save asdf913/96b0f4738b9669be2297aa3f43624cad to your computer and use it in GitHub Desktop.
How to detect current Operation System of by "java.nio.file.spi.FileSystemProvider" class and "java.nio.file.FileSystems.getDefault()" method in Java
import java.nio.file.FileSystems;
import java.nio.file.spi.FileSystemProvider;
import java.nio.file.FileSystem;
public class HelloWorld {
public static void main(final String[] args) {
final FileSystem fs=FileSystems.getDefault();
final FileSystemProvider fsp=fs!=null?fs.provider():null;
System.out.println(fsp!=null?fsp.getClass():null);
}
}
@asdf913
Copy link
Author

asdf913 commented Apr 2, 2023

Operating Systemjava.nio.file.spi.FileSystemProvider implementation
Microsoft Windowssun.nio.fs.WindowsFileSystemProvider
Linuxsun.nio.fs.LinuxFileSystemProvider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment