当前位置: 首页>>代码示例>>Java>>正文


Java FileTypeDetector类代码示例

本文整理汇总了Java中java.nio.file.spi.FileTypeDetector的典型用法代码示例。如果您正苦于以下问题:Java FileTypeDetector类的具体用法?Java FileTypeDetector怎么用?Java FileTypeDetector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileTypeDetector类属于java.nio.file.spi包,在下文中一共展示了FileTypeDetector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的java.nio.file.spi.FileTypeDetector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。