+ @SuppressWarnings("unchecked")
+ @Override
+ public <C extends Closeable> C open(Class<C> clss) throws IOException, IllegalArgumentException {
+ if (InputStream.class.isAssignableFrom(clss)) {
+ if (Files.isDirectory(path))
+ throw new UnsupportedOperationException("Cannot open " + path + " as stream, since it is a directory");
+ return (C) Files.newInputStream(path);
+ } else if (OutputStream.class.isAssignableFrom(clss)) {
+ if (Files.isDirectory(path))
+ throw new UnsupportedOperationException("Cannot open " + path + " as stream, since it is a directory");
+ return (C) Files.newOutputStream(path);
+ }
+ return super.open(clss);
+ }
+