Search code examples
javafilesystemsniojava-7java-6

Java 7 FileSystemProvider backward compatibility


We are building a new Java 7 NIO.2 FileSystemProvider, and would like to not exclude Java 6 users. Is there any good strategy for supporting Java 6 users? Is it better to build something compatible with Java 6 and then build the new API on top?


Solution

  • That depends on which features you use. NIO2 has some features which you simply can't replicate in Java 6.

    But to way to go is to create an interface which contains the functionality that you need and then write two implementations. At runtime, you can then check the Java version and use reflection to instantiate the correct one.