本文整理汇总了Java中java.nio.file.spi.FileTypeDetector类的典型用法代码示例。如果您正苦于以下问题:Java FileTypeDetector类的具体用法?Java FileTypeDetector怎么用?Java FileTypeDetector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileTypeDetector类属于java.nio.file.spi包,在下文中一共展示了FileTypeDetector类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testFileExtension
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
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;
}
};
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:16,代码来源:FileTypeDetectorTest.java
示例2: createDefaultFileTypeDetector
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
private static FileTypeDetector createDefaultFileTypeDetector() {
return AccessController
.doPrivileged(new PrivilegedAction<FileTypeDetector>() {
@Override public FileTypeDetector run() {
return sun.nio.fs.DefaultFileTypeDetector.create();
}});
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:Files.java
示例3: loadInstalledDetectors
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
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;
}});
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:Files.java
示例4: getFileTypeDetector
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
/**
* Returns a {@code FileTypeDetector} for this platform.
*/
FileTypeDetector getFileTypeDetector() {
return new AbstractFileTypeDetector() {
@Override
public String implProbeContentType(Path file) {
return null;
}
};
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:UnixFileSystemProvider.java
示例5: chain
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
/**
* 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;
}
};
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:UnixFileSystemProvider.java
示例6: getFileTypeDetector
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
@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());
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:LinuxFileSystemProvider.java
示例7: getFileTypeDetector
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
@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));
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:SolarisFileSystemProvider.java
示例8: create
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
public static FileTypeDetector create()
{
return new AbstractFileTypeDetector() {
public String implProbeContentType(Path obj) throws IOException {
return null;
}
};
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:DefaultFileTypeDetector.java
示例9: createDefaultFileTypeDetector
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
private static FileTypeDetector createDefaultFileTypeDetector() {
return AccessController
.doPrivileged(new PrivilegedAction<>() {
@Override public FileTypeDetector run() {
return sun.nio.fs.DefaultFileTypeDetector.create();
}});
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:Files.java
示例10: loadInstalledDetectors
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
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;
}});
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:Files.java
示例11: getFileTypeDetector
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
@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));
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:LinuxFileSystemProvider.java
示例12: getFileTypeDetector
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
@Override
FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get(GetPropertyAction
.privilegedGetProperty("user.home"), ".mime.types");
return chain(new MimeTypesFileTypeDetector(userMimeTypes),
new UTIFileTypeDetector());
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:MacOSXFileSystemProvider.java
示例13: getFileTypeDetector
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
@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));
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:SolarisFileSystemProvider.java
示例14: getFileTypeDetector
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
@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());
}
开发者ID:campolake,项目名称:openjdk9,代码行数:12,代码来源:LinuxFileSystemProvider.java
示例15: getFileTypeDetector
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
@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));
}
开发者ID:campolake,项目名称:openjdk9,代码行数:11,代码来源:SolarisFileSystemProvider.java
示例16: getInstalledDetectors
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
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;
}
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:10,代码来源:MCRContentTypes.java
示例17: probeContentType
import java.nio.file.spi.FileTypeDetector; //导入依赖的package包/类
/**
* 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);
}
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:22,代码来源:MCRContentTypes.java
注:本文中的java.nio.file.spi.FileTypeDetector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论