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 Project: jdk1.8-source-analysis   Author: raysonfang   File: Files.java    License: Apache License 2.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 #2
Source Project: jdk8u-dev-jdk   Author: frohoff   File: Files.java    License: 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 #3
Source Project: hottub   Author: dsrg-uoft   File: Files.java    License: 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 #4
Source Project: dragonwell8_jdk   Author: alibaba   File: Files.java    License: 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 #5
Source Project: dragonwell8_jdk   Author: alibaba   File: Files.java    License: 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 #6
Source Project: dragonwell8_jdk   Author: alibaba   File: LinuxFileSystemProvider.java    License: 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 #7
Source Project: openjdk-8   Author: bpupadhyaya   File: Files.java    License: 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 #8
Source Project: TencentKona-8   Author: Tencent   File: Files.java    License: 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 Project: TencentKona-8   Author: Tencent   File: Files.java    License: 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 Project: openjdk-8   Author: bpupadhyaya   File: Files.java    License: 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 Project: TencentKona-8   Author: Tencent   File: UnixFileSystemProvider.java    License: 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 Project: TencentKona-8   Author: Tencent   File: UnixFileSystemProvider.java    License: 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 Project: TencentKona-8   Author: Tencent   File: LinuxFileSystemProvider.java    License: 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 Project: hottub   Author: dsrg-uoft   File: Files.java    License: 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 #15
Source Project: jdk8u60   Author: chenghanpeng   File: Files.java    License: 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 #16
Source Project: jdk8u-dev-jdk   Author: frohoff   File: UnixFileSystemProvider.java    License: 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 #17
Source Project: jdk8u60   Author: chenghanpeng   File: UnixFileSystemProvider.java    License: 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 #18
Source Project: jdk8u60   Author: chenghanpeng   File: UnixFileSystemProvider.java    License: 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 #19
Source Project: jdk8u-jdk   Author: frohoff   File: UnixFileSystemProvider.java    License: 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 Project: JDKSourceCode1.8   Author: wupeixuan   File: Files.java    License: 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();
        }});
}
 
Example #21
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: Files.java    License: 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 #22
Source Project: jdk-1.7-annotated   Author: ZhaoX   File: Files.java    License: 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 #23
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Files.java    License: 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 #24
Source Project: hottub   Author: dsrg-uoft   File: LinuxFileSystemProvider.java    License: 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 Project: jdk8u_jdk   Author: JetBrains   File: SolarisFileSystemProvider.java    License: 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 Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: LinuxFileSystemProvider.java    License: 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 Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: SolarisFileSystemProvider.java    License: 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 #28
Source Project: jdk8u-dev-jdk   Author: frohoff   File: Files.java    License: 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 #29
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: Files.java    License: 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 #30
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: Files.java    License: 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;
        }});
}