java.nio.file.spi.FileTypeDetector Java Examples

The following examples show how to use java.nio.file.spi.FileTypeDetector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Files.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private static FileTypeDetector createDefaultFileTypeDetector() {
    return AccessController
        .doPrivileged(new PrivilegedAction<>() {
            @Override public FileTypeDetector run() {
                return sun.nio.fs.DefaultFileTypeDetector.create();
        }});
}
 
Example #2
Source File: UnixFileSystemProvider.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a {@code FileTypeDetector} for this platform.
 */
FileTypeDetector getFileTypeDetector() {
    return new AbstractFileTypeDetector() {
        @Override
        public String implProbeContentType(Path file) {
            return null;
        }
    };
}
 
Example #3
Source File: UnixFileSystemProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a {@code FileTypeDetector} that chains the given array of file
 * type detectors. When the {@code implProbeContentType} method is invoked
 * then each of the detectors is invoked in turn, the result from the
 * first to detect the file type is returned.
 */
final FileTypeDetector chain(final AbstractFileTypeDetector... detectors) {
    return new AbstractFileTypeDetector() {
        @Override
        protected String implProbeContentType(Path file) throws IOException {
            for (AbstractFileTypeDetector detector : detectors) {
                String result = detector.implProbeContentType(file);
                if (result != null && !result.isEmpty()) {
                    return result;
                }
            }
            return null;
        }
    };
}
 
Example #4
Source File: Files.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static List<FileTypeDetector> loadInstalledDetectors() {
    return AccessController
        .doPrivileged(new PrivilegedAction<List<FileTypeDetector>>() {
            @Override public List<FileTypeDetector> run() {
                List<FileTypeDetector> list = new ArrayList<>();
                ServiceLoader<FileTypeDetector> loader = ServiceLoader
                    .load(FileTypeDetector.class, ClassLoader.getSystemClassLoader());
                for (FileTypeDetector detector: loader) {
                    list.add(detector);
                }
                return list;
        }});
}
 
Example #5
Source File: Files.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static FileTypeDetector createDefaultFileTypeDetector() {
    return AccessController
        .doPrivileged(new PrivilegedAction<>() {
            @Override public FileTypeDetector run() {
                return sun.nio.fs.DefaultFileTypeDetector.create();
        }});
}
 
Example #6
Source File: Files.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static FileTypeDetector createDefaultFileTypeDetector() {
    return AccessController
        .doPrivileged(new PrivilegedAction<FileTypeDetector>() {
            @Override public FileTypeDetector run() {
                return sun.nio.fs.DefaultFileTypeDetector.create();
        }});
}
 
Example #7
Source File: LinuxFileSystemProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
FileTypeDetector getFileTypeDetector() {
    String userHome = GetPropertyAction.privilegedGetProperty("user.home");
    Path userMimeTypes = Paths.get(userHome, ".mime.types");
    Path etcMimeTypes = Paths.get("/etc/mime.types");

    return chain(new MimeTypesFileTypeDetector(userMimeTypes),
                 new MimeTypesFileTypeDetector(etcMimeTypes));
}
 
Example #8
Source File: Files.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static FileTypeDetector createDefaultFileTypeDetector() {
    return AccessController
        .doPrivileged(new PrivilegedAction<FileTypeDetector>() {
            @Override public FileTypeDetector run() {
                return sun.nio.fs.DefaultFileTypeDetector.create();
        }});
}
 
Example #9
Source File: Files.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static List<FileTypeDetector> loadInstalledDetectors() {
    return AccessController
        .doPrivileged(new PrivilegedAction<List<FileTypeDetector>>() {
            @Override public List<FileTypeDetector> run() {
                List<FileTypeDetector> list = new ArrayList<>();
                ServiceLoader<FileTypeDetector> loader = ServiceLoader
                    .load(FileTypeDetector.class, ClassLoader.getSystemClassLoader());
                for (FileTypeDetector detector: loader) {
                    list.add(detector);
                }
                return list;
        }});
}
 
Example #10
Source File: Files.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static FileTypeDetector createDefaultFileTypeDetector() {
    return AccessController
        .doPrivileged(new PrivilegedAction<FileTypeDetector>() {
            @Override public FileTypeDetector run() {
                return sun.nio.fs.DefaultFileTypeDetector.create();
        }});
}
 
Example #11
Source File: UnixFileSystemProvider.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a {@code FileTypeDetector} for this platform.
 */
FileTypeDetector getFileTypeDetector() {
    return new AbstractFileTypeDetector() {
        @Override
        public String implProbeContentType(Path file) {
            return null;
        }
    };
}
 
Example #12
Source File: UnixFileSystemProvider.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a {@code FileTypeDetector} that chains the given array of file
 * type detectors. When the {@code implProbeContentType} method is invoked
 * then each of the detectors is invoked in turn, the result from the
 * first to detect the file type is returned.
 */
final FileTypeDetector chain(final AbstractFileTypeDetector... detectors) {
    return new AbstractFileTypeDetector() {
        @Override
        protected String implProbeContentType(Path file) throws IOException {
            for (AbstractFileTypeDetector detector : detectors) {
                String result = detector.implProbeContentType(file);
                if (result != null && !result.isEmpty()) {
                    return result;
                }
            }
            return null;
        }
    };
}
 
Example #13
Source File: LinuxFileSystemProvider.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
FileTypeDetector getFileTypeDetector() {
    Path userMimeTypes = Paths.get(AccessController.doPrivileged(
        new GetPropertyAction("user.home")), ".mime.types");
    Path etcMimeTypes = Paths.get("/etc/mime.types");

    return chain(new GnomeFileTypeDetector(),
                 new MimeTypesFileTypeDetector(userMimeTypes),
                 new MimeTypesFileTypeDetector(etcMimeTypes),
                 new MagicFileTypeDetector());
}
 
Example #14
Source File: UnixFileSystemProvider.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a {@code FileTypeDetector} that chains the given array of file
 * type detectors. When the {@code implProbeContentType} method is invoked
 * then each of the detectors is invoked in turn, the result from the
 * first to detect the file type is returned.
 */
final FileTypeDetector chain(final AbstractFileTypeDetector... detectors) {
    return new AbstractFileTypeDetector() {
        @Override
        protected String implProbeContentType(Path file) throws IOException {
            for (AbstractFileTypeDetector detector : detectors) {
                String result = detector.implProbeContentType(file);
                if (result != null && !result.isEmpty()) {
                    return result;
                }
            }
            return null;
        }
    };
}
 
Example #15
Source File: SolarisFileSystemProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
FileTypeDetector getFileTypeDetector() {
    Path userMimeTypes = Paths.get(
        GetPropertyAction.privilegedGetProperty("user.home"), ".mime.types");
    Path etcMimeTypes = Paths.get("/etc/mime.types");

    return chain(new MimeTypesFileTypeDetector(userMimeTypes),
                 new MimeTypesFileTypeDetector(etcMimeTypes));
}
 
Example #16
Source File: Files.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private static List<FileTypeDetector> loadInstalledDetectors() {
    return AccessController
        .doPrivileged(new PrivilegedAction<>() {
            @Override public List<FileTypeDetector> run() {
                List<FileTypeDetector> list = new ArrayList<>();
                ServiceLoader<FileTypeDetector> loader = ServiceLoader
                    .load(FileTypeDetector.class, ClassLoader.getSystemClassLoader());
                for (FileTypeDetector detector: loader) {
                    list.add(detector);
                }
                return list;
        }});
}
 
Example #17
Source File: SolarisFileSystemProvider.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
FileTypeDetector getFileTypeDetector() {
    Path userMimeTypes = Paths.get(AccessController.doPrivileged(
        new GetPropertyAction("user.home")), ".mime.types");
    Path etcMimeTypes = Paths.get("/etc/mime.types");

    return chain(new GnomeFileTypeDetector(),
                 new MimeTypesFileTypeDetector(userMimeTypes),
                 new MimeTypesFileTypeDetector(etcMimeTypes));
}
 
Example #18
Source File: Files.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static List<FileTypeDetector> loadInstalledDetectors() {
    return AccessController
        .doPrivileged(new PrivilegedAction<List<FileTypeDetector>>() {
            @Override public List<FileTypeDetector> run() {
                List<FileTypeDetector> list = new ArrayList<>();
                ServiceLoader<FileTypeDetector> loader = ServiceLoader
                    .load(FileTypeDetector.class, ClassLoader.getSystemClassLoader());
                for (FileTypeDetector detector: loader) {
                    list.add(detector);
                }
                return list;
        }});
}
 
Example #19
Source File: UnixFileSystemProvider.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a {@code FileTypeDetector} for this platform.
 */
FileTypeDetector getFileTypeDetector() {
    return new AbstractFileTypeDetector() {
        @Override
        public String implProbeContentType(Path file) {
            return null;
        }
    };
}
 
Example #20
Source File: Files.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static List<FileTypeDetector> loadInstalledDetectors() {
    return AccessController
        .doPrivileged(new PrivilegedAction<List<FileTypeDetector>>() {
            @Override public List<FileTypeDetector> run() {
                List<FileTypeDetector> list = new ArrayList<>();
                ServiceLoader<FileTypeDetector> loader = ServiceLoader
                    .load(FileTypeDetector.class, ClassLoader.getSystemClassLoader());
                for (FileTypeDetector detector: loader) {
                    list.add(detector);
                }
                return list;
        }});
}
 
Example #21
Source File: Files.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static FileTypeDetector createDefaultFileTypeDetector() {
    return AccessController
        .doPrivileged(new PrivilegedAction<FileTypeDetector>() {
            @Override public FileTypeDetector run() {
                return sun.nio.fs.DefaultFileTypeDetector.create();
        }});
}
 
Example #22
Source File: Files.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static FileTypeDetector createDefaultFileTypeDetector() {
    return AccessController
        .doPrivileged(new PrivilegedAction<FileTypeDetector>() {
            @Override public FileTypeDetector run() {
                return sun.nio.fs.DefaultFileTypeDetector.create();
        }});
}
 
Example #23
Source File: SolarisFileSystemProvider.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
FileTypeDetector getFileTypeDetector() {
    Path userMimeTypes = Paths.get(AccessController.doPrivileged(
        new GetPropertyAction("user.home")), ".mime.types");
    Path etcMimeTypes = Paths.get("/etc/mime.types");

    return chain(new GnomeFileTypeDetector(),
                 new MimeTypesFileTypeDetector(userMimeTypes),
                 new MimeTypesFileTypeDetector(etcMimeTypes));
}
 
Example #24
Source File: LinuxFileSystemProvider.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
FileTypeDetector getFileTypeDetector() {
    Path userMimeTypes = Paths.get(AccessController.doPrivileged(
        new GetPropertyAction("user.home")), ".mime.types");
    Path etcMimeTypes = Paths.get("/etc/mime.types");

    return chain(new GnomeFileTypeDetector(),
                 new MimeTypesFileTypeDetector(userMimeTypes),
                 new MimeTypesFileTypeDetector(etcMimeTypes),
                 new MagicFileTypeDetector());
}
 
Example #25
Source File: SolarisFileSystemProvider.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
FileTypeDetector getFileTypeDetector() {
    Path userMimeTypes = Paths.get(AccessController.doPrivileged(
        new GetPropertyAction("user.home")), ".mime.types");
    Path etcMimeTypes = Paths.get("/etc/mime.types");

    return chain(new GnomeFileTypeDetector(),
                 new MimeTypesFileTypeDetector(userMimeTypes),
                 new MimeTypesFileTypeDetector(etcMimeTypes));
}
 
Example #26
Source File: LinuxFileSystemProvider.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
FileTypeDetector getFileTypeDetector() {
    Path userMimeTypes = Paths.get(AccessController.doPrivileged(
        new GetPropertyAction("user.home")), ".mime.types");
    Path etcMimeTypes = Paths.get("/etc/mime.types");

    return chain(new GnomeFileTypeDetector(),
                 new MimeTypesFileTypeDetector(userMimeTypes),
                 new MimeTypesFileTypeDetector(etcMimeTypes),
                 new MagicFileTypeDetector());
}
 
Example #27
Source File: Files.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static List<FileTypeDetector> loadInstalledDetectors() {
    return AccessController
        .doPrivileged(new PrivilegedAction<List<FileTypeDetector>>() {
            @Override public List<FileTypeDetector> run() {
                List<FileTypeDetector> list = new ArrayList<>();
                ServiceLoader<FileTypeDetector> loader = ServiceLoader
                    .load(FileTypeDetector.class, ClassLoader.getSystemClassLoader());
                for (FileTypeDetector detector: loader) {
                    list.add(detector);
                }
                return list;
        }});
}
 
Example #28
Source File: Files.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
private static List<FileTypeDetector> loadInstalledDetectors() {
    return AccessController
        .doPrivileged(new PrivilegedAction<List<FileTypeDetector>>() {
            @Override public List<FileTypeDetector> run() {
                List<FileTypeDetector> list = new ArrayList<>();
                ServiceLoader<FileTypeDetector> loader = ServiceLoader
                    .load(FileTypeDetector.class, ClassLoader.getSystemClassLoader());
                for (FileTypeDetector detector: loader) {
                    list.add(detector);
                }
                return list;
        }});
}
 
Example #29
Source File: Files.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private static List<FileTypeDetector> loadInstalledDetectors() {
    return AccessController
        .doPrivileged(new PrivilegedAction<List<FileTypeDetector>>() {
            @Override public List<FileTypeDetector> run() {
                List<FileTypeDetector> list = new ArrayList<>();
                ServiceLoader<FileTypeDetector> loader = ServiceLoader
                    .load(FileTypeDetector.class, ClassLoader.getSystemClassLoader());
                for (FileTypeDetector detector: loader) {
                    list.add(detector);
                }
                return list;
        }});
}
 
Example #30
Source File: Files.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private static FileTypeDetector createDefaultFileTypeDetector() {
    return AccessController
        .doPrivileged(new PrivilegedAction<FileTypeDetector>() {
            @Override public FileTypeDetector run() {
                return sun.nio.fs.DefaultFileTypeDetector.create();
        }});
}