Java 类java.nio.file.spi.FileTypeDetector 实例源码
项目:openjdk-systemtest
文件:FileTypeDetectorTest.java
public void testFileExtension() throws IOException{
new FileTypeDetector() {
@Override
public String probeContentType(Path file) throws IOException {
String type;
// Basic check on the type using the filename
if (file.toString().lastIndexOf('.') != -1) {
type = file.toString().substring( file.toString().lastIndexOf('.') );
} else {
type = null;
}
return type;
}
};
}
项目:OpenJSharp
文件:Files.java
private static FileTypeDetector createDefaultFileTypeDetector() {
return AccessController
.doPrivileged(new PrivilegedAction<FileTypeDetector>() {
@Override public FileTypeDetector run() {
return sun.nio.fs.DefaultFileTypeDetector.create();
}});
}
项目:OpenJSharp
文件:Files.java
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;
}});
}
项目:OpenJSharp
文件:UnixFileSystemProvider.java
/**
* Returns a {@code FileTypeDetector} for this platform.
*/
FileTypeDetector getFileTypeDetector() {
return new AbstractFileTypeDetector() {
@Override
public String implProbeContentType(Path file) {
return null;
}
};
}
项目:OpenJSharp
文件:UnixFileSystemProvider.java
/**
* 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;
}
};
}
项目:OpenJSharp
文件:LinuxFileSystemProvider.java
@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());
}
项目:OpenJSharp
文件:SolarisFileSystemProvider.java
@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));
}
项目:OpenJSharp
文件:DefaultFileTypeDetector.java
public static FileTypeDetector create()
{
return new AbstractFileTypeDetector() {
public String implProbeContentType(Path obj) throws IOException {
return null;
}
};
}
项目:jdk8u-jdk
文件:Files.java
private static FileTypeDetector createDefaultFileTypeDetector() {
return AccessController
.doPrivileged(new PrivilegedAction<FileTypeDetector>() {
@Override public FileTypeDetector run() {
return sun.nio.fs.DefaultFileTypeDetector.create();
}});
}
项目:jdk8u-jdk
文件:Files.java
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;
}});
}
项目:jdk8u-jdk
文件:UnixFileSystemProvider.java
/**
* Returns a {@code FileTypeDetector} for this platform.
*/
FileTypeDetector getFileTypeDetector() {
return new AbstractFileTypeDetector() {
@Override
public String implProbeContentType(Path file) {
return null;
}
};
}
项目:jdk8u-jdk
文件:UnixFileSystemProvider.java
/**
* 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;
}
};
}
项目:jdk8u-jdk
文件:LinuxFileSystemProvider.java
@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());
}
项目:jdk8u-jdk
文件:SolarisFileSystemProvider.java
@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));
}
项目:openjdk-jdk10
文件:Files.java
private static FileTypeDetector createDefaultFileTypeDetector() {
return AccessController
.doPrivileged(new PrivilegedAction<>() {
@Override public FileTypeDetector run() {
return sun.nio.fs.DefaultFileTypeDetector.create();
}});
}
项目:openjdk-jdk10
文件:Files.java
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;
}});
}
项目:openjdk-jdk10
文件:LinuxFileSystemProvider.java
@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));
}
项目:openjdk-jdk10
文件:UnixFileSystemProvider.java
/**
* Returns a {@code FileTypeDetector} for this platform.
*/
FileTypeDetector getFileTypeDetector() {
return new AbstractFileTypeDetector() {
@Override
public String implProbeContentType(Path file) {
return null;
}
};
}
项目:openjdk-jdk10
文件:UnixFileSystemProvider.java
/**
* 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;
}
};
}
项目:openjdk-jdk10
文件:MacOSXFileSystemProvider.java
@Override
FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get(GetPropertyAction
.privilegedGetProperty("user.home"), ".mime.types");
return chain(new MimeTypesFileTypeDetector(userMimeTypes),
new UTIFileTypeDetector());
}
项目:openjdk-jdk10
文件:SolarisFileSystemProvider.java
@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));
}
项目:openjdk9
文件:Files.java
private static FileTypeDetector createDefaultFileTypeDetector() {
return AccessController
.doPrivileged(new PrivilegedAction<>() {
@Override public FileTypeDetector run() {
return sun.nio.fs.DefaultFileTypeDetector.create();
}});
}
项目:openjdk9
文件:Files.java
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;
}});
}
项目:openjdk9
文件:LinuxFileSystemProvider.java
@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 GioFileTypeDetector(),
new MimeTypesFileTypeDetector(userMimeTypes),
new MimeTypesFileTypeDetector(etcMimeTypes),
new MagicFileTypeDetector());
}
项目:openjdk9
文件:UnixFileSystemProvider.java
/**
* Returns a {@code FileTypeDetector} for this platform.
*/
FileTypeDetector getFileTypeDetector() {
return new AbstractFileTypeDetector() {
@Override
public String implProbeContentType(Path file) {
return null;
}
};
}
项目:openjdk9
文件:UnixFileSystemProvider.java
/**
* 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;
}
};
}
项目:openjdk9
文件:MacOSXFileSystemProvider.java
@Override
FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get(GetPropertyAction
.privilegedGetProperty("user.home"), ".mime.types");
return chain(new MimeTypesFileTypeDetector(userMimeTypes),
new UTIFileTypeDetector());
}
项目:openjdk9
文件:SolarisFileSystemProvider.java
@Override
FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get(
GetPropertyAction.privilegedGetProperty("user.home"), ".mime.types");
Path etcMimeTypes = Paths.get("/etc/mime.types");
return chain(new GioFileTypeDetector(),
new MimeTypesFileTypeDetector(userMimeTypes),
new MimeTypesFileTypeDetector(etcMimeTypes));
}
项目:Java8CN
文件:Files.java
private static FileTypeDetector createDefaultFileTypeDetector() {
return AccessController
.doPrivileged(new PrivilegedAction<FileTypeDetector>() {
@Override public FileTypeDetector run() {
return sun.nio.fs.DefaultFileTypeDetector.create();
}});
}
项目:Java8CN
文件:Files.java
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;
}});
}
项目:mycore
文件:MCRContentTypes.java
private static List<FileTypeDetector> getInstalledDetectors() {
ArrayList<FileTypeDetector> detectors = new ArrayList<>();
ServiceLoader<FileTypeDetector> serviceLoader = ServiceLoader.load(FileTypeDetector.class);
for (FileTypeDetector fileTypeDetector : serviceLoader) {
LOGGER.info("Adding content type detector: {}", fileTypeDetector.getClass());
detectors.add(fileTypeDetector);
}
return detectors;
}
项目:mycore
文件:MCRContentTypes.java
/**
* Probes the content type of a file.
*
* Same as {@link Files#probeContentType(Path)} but uses context class loader.
* @param path
* the path to the file to probe
* @return The content type of the file, or null if the content type cannot be determined
* @throws IOException if an I/O error occurs
*/
public static String probeContentType(Path path) throws IOException {
LOGGER.debug("Probing content type: {}", path);
for (FileTypeDetector fileTypeDetector : fileTypeDetectors) {
LOGGER.debug("Using type detector: {}", fileTypeDetector.getClass());
String contentType = fileTypeDetector.probeContentType(path);
if (contentType != null) {
LOGGER.debug("Content type: {}", contentType);
return contentType;
}
}
return Files.probeContentType(path);
}
项目:jdk8u_jdk
文件:Files.java
private static FileTypeDetector createDefaultFileTypeDetector() {
return AccessController
.doPrivileged(new PrivilegedAction<FileTypeDetector>() {
@Override public FileTypeDetector run() {
return sun.nio.fs.DefaultFileTypeDetector.create();
}});
}
项目:jdk8u_jdk
文件:Files.java
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;
}});
}
项目:jdk8u_jdk
文件:UnixFileSystemProvider.java
/**
* Returns a {@code FileTypeDetector} for this platform.
*/
FileTypeDetector getFileTypeDetector() {
return new AbstractFileTypeDetector() {
@Override
public String implProbeContentType(Path file) {
return null;
}
};
}
项目:jdk8u_jdk
文件:UnixFileSystemProvider.java
/**
* 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;
}
};
}
项目:jdk8u_jdk
文件:LinuxFileSystemProvider.java
@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());
}
项目:jdk8u_jdk
文件:SolarisFileSystemProvider.java
@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));
}
项目:lookaside_java-1.8.0-openjdk
文件:Files.java
private static FileTypeDetector createDefaultFileTypeDetector() {
return AccessController
.doPrivileged(new PrivilegedAction<FileTypeDetector>() {
@Override public FileTypeDetector run() {
return sun.nio.fs.DefaultFileTypeDetector.create();
}});
}
项目:lookaside_java-1.8.0-openjdk
文件:Files.java
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;
}});
}