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


Java Path.getFileSystem方法代码示例

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


在下文中一共展示了Path.getFileSystem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mockPath

import java.nio.file.Path; //导入方法依赖的package包/类
protected Path mockPath(Path parent, String name, long size) {
	FileSystem fileSystem = parent.getFileSystem();
	Path subPath = mock(Path.class);
	File subPathToFile = mock(File.class);
	when(subPath.toFile()).thenReturn(subPathToFile);
	when(subPathToFile.length()).thenReturn(size);
	when(subPathToFile.exists()).thenReturn(true);
	when(subPath.getFileSystem()).thenReturn(fileSystem);
	when(subPath.resolve(anyString())).thenAnswer(invoke -> {
		String childName = (String) invoke.getArguments()[0];
		return mockPath(subPath, childName);
	});
	when(subPath.getParent()).thenReturn(parent);
	when(fileSystem.getPath(parent.toString(), name)).thenReturn(subPath);
	String fullPath = (parent.toString() + "/" + name).replace("//", "/");
	when(fileSystem.getPath(fullPath)).thenReturn(subPath);
	when(subPath.toString()).thenReturn(fullPath);
	Path subPathFileName = mock(Path.class);
	when(subPathFileName.toString()).thenReturn(name);
	when(subPath.getFileName()).thenReturn(subPathFileName);
	return subPath;
}
 
开发者ID:tfiskgul,项目名称:mux2fs,代码行数:23,代码来源:Fixture.java

示例2: main

import java.nio.file.Path; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    FileSystem fs = FileSystems.getDefault();
    if (fs.getClass().getModule() == Object.class.getModule())
        throw new RuntimeException("FileSystemProvider not overridden");

    // exercise the file system
    Path dir = Files.createTempDirectory("tmp");
    if (dir.getFileSystem() != fs)
        throw new RuntimeException("'dir' not in default file system");
    System.out.println("created: " + dir);

    Path foo = Files.createFile(dir.resolve("foo"));
    if (foo.getFileSystem() != fs)
        throw new RuntimeException("'foo' not in default file system");
    System.out.println("created: " + foo);

    // exercise interop with java.io.File
    File file = foo.toFile();
    Path path = file.toPath();
    if (path.getFileSystem() != fs)
        throw new RuntimeException("'path' not in default file system");
    if (!path.equals(foo))
        throw new RuntimeException(path + " not equal to " + foo);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:Main.java

示例3: MirrorFs

import java.nio.file.Path; //导入方法依赖的package包/类
@VisibleForTesting
protected MirrorFs(Path mirroredPath, FileChannelCloser fileChannelCloser) {
	super();
	this.mirroredRoot = mirroredPath.toString();
	this.fileSystem = mirroredPath.getFileSystem();
	this.fileChannelCloser = fileChannelCloser;
}
 
开发者ID:tfiskgul,项目名称:mux2fs,代码行数:8,代码来源:MirrorFs.java

示例4: FaultyFileSystem

import java.nio.file.Path; //导入方法依赖的package包/类
FaultyFileSystem(Path root) throws IOException {
    if (root == null) {
        root = Files.createTempDirectory("faultyFS");
        removeRootAfterClose = true;
    } else {
        if (! Files.isDirectory(root)) {
            throw new IllegalArgumentException("must be a directory.");
        }
        removeRootAfterClose = false;
    }
    this.root = root;
    delegate = root.getFileSystem();
    isOpen = true;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:FaultyFileSystem.java

示例5: isPathNameCompatible

import java.nio.file.Path; //导入方法依赖的package包/类
protected boolean isPathNameCompatible(Path p, String simpleName, Kind kind) {
    Objects.requireNonNull(simpleName);
    Objects.requireNonNull(kind);

    if (kind == Kind.OTHER && BaseFileManager.getKind(p) != kind) {
        return false;
    }

    String sn = simpleName + kind.extension;
    String pn = p.getFileName().toString();
    if (pn.equals(sn)) {
        return true;
    }

    if (p.getFileSystem() == defaultFileSystem) {
        if (isMacOS) {
            if (Normalizer.isNormalized(pn, Normalizer.Form.NFD)
                    && Normalizer.isNormalized(sn, Normalizer.Form.NFC)) {
                // On Mac OS X it is quite possible to have the file name and the
                // given simple name normalized in different ways.
                // In that case we have to normalize file name to the
                // Normal Form Composed (NFC).
                String normName = Normalizer.normalize(pn, Normalizer.Form.NFC);
                if (normName.equals(sn)) {
                    return true;
                }
            }
        }

        if (pn.equalsIgnoreCase(sn)) {
            try {
                // allow for Windows
                return p.toRealPath(LinkOption.NOFOLLOW_LINKS).getFileName().toString().equals(sn);
            } catch (IOException e) {
            }
        }
    }

    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:PathFileObject.java

示例6: contains

import java.nio.file.Path; //导入方法依赖的package包/类
private boolean contains(Collection<Path> searchPath, Path file) throws IOException {

        if (searchPath == null) {
            return false;
        }

        Path enclosingJar = null;
        if (file.getFileSystem().provider() == fsInfo.getJarFSProvider()) {
            URI uri = file.toUri();
            if (uri.getScheme().equals("jar")) {
                String ssp = uri.getSchemeSpecificPart();
                int sep = ssp.lastIndexOf("!");
                if (ssp.startsWith("file:") && sep > 0) {
                    enclosingJar = Paths.get(URI.create(ssp.substring(0, sep)));
                }
            }
        }

        Path nf = normalize(file);
        for (Path p : searchPath) {
            Path np = normalize(p);
            if (np.getFileSystem() == nf.getFileSystem()
                    && Files.isDirectory(np)
                    && nf.startsWith(np)) {
                return true;
            }
            if (enclosingJar != null
                    && Files.isSameFile(enclosingJar, np)) {
                return true;
            }
        }

        return false;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:Locations.java

示例7: isInJRT

import java.nio.file.Path; //导入方法依赖的package包/类
public boolean isInJRT(FileObject fo) {
    if (fo instanceof PathFileObject) {
        Path path = ((PathFileObject) fo).getPath();
        return (path.getFileSystem() == jrtfs);
    } else {
        return false;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:JRTIndex.java

示例8: ConversionFileWriterWrapper

import java.nio.file.Path; //导入方法依赖的package包/类
public ConversionFileWriterWrapper(Path inFile) {
	this.source = new PathSource(inFile);

	fileSystem = inFile.getFileSystem();
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:6,代码来源:ConversionFileWriterWrapper.java

示例9: resolve

import java.nio.file.Path; //导入方法依赖的package包/类
private static Path resolve(Path base, String relativePath) {
    FileSystem fs = base.getFileSystem();
    Path rp = fs.getPath(relativePath.replace("/", fs.getSeparator()));
    return base.resolve(rp);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:JavacPathFileManager.java

示例10: createAppSkeleton

import java.nio.file.Path; //导入方法依赖的package包/类
private static Observable<Event> createAppSkeleton(final Path projectDirectory, final Project project) {

        Preconditions.checkNotNull(projectDirectory);
        Preconditions.checkNotNull(project);

        final FileSystem fs = projectDirectory.getFileSystem();
        final Identifier projectIdentifier = project.name.map(StringUtils::escapeStringGitHubStyle)
            .flatMap(Identifier::parse)
            .orElseGet(() -> Identifier.of("my-project"));

        return Observable.concat(ImmutableList.of(

            // Write the project file
            CommonTasks.writeFile(
                Serializers.serialize(project),
                fs.getPath("buckaroo.json").toAbsolutePath(),
                false)
                .toObservable()
                .cast(Event.class)
                .onErrorReturnItem(Notification.of("buckaroo.json already exists!")),

            // Touch the .buckconfig
            CommonTasks.touchFile(fs.getPath(projectDirectory.toString(), ".buckconfig"))
                .toObservable(),

            // Generate an empty BUCKAROO_DEPS
            Single.fromCallable(() -> CommonTasks.generateBuckarooDeps(ImmutableList.of()))
                .flatMap(content ->
                    CommonTasks.writeFile(
                        content,
                        fs.getPath(projectDirectory.toString(), "BUCKAROO_DEPS"),
                        false))
                .toObservable()
                .cast(Event.class)
                .onErrorReturnItem(Notification.of("BUCKAROO_DEPS already exists!")),

            // Create the project directories
            CommonTasks.createDirectory(fs.getPath(projectDirectory.toString(), projectIdentifier.name))
                .toObservable(),

            CommonTasks.createDirectory(fs.getPath(projectDirectory.toString(), projectIdentifier.name, "src"))
                .toObservable(),

            CommonTasks.createDirectory(fs.getPath(projectDirectory.toString(), projectIdentifier.name, "include"))
                .toObservable(),

            CommonTasks.createDirectory(fs.getPath(projectDirectory.toString(), projectIdentifier.name, "detail"))
                .toObservable(),

            // Write the Hello World cpp file
            Single.fromCallable(QuickstartTasks::helloWorldCpp).flatMap(content -> CommonTasks.writeFile(
                content,
                fs.getPath(projectDirectory.toString(), projectIdentifier.name, "apps", "main.cpp"),
                false))
                .toObservable()
                .cast(Event.class)
                .onErrorReturnItem(Notification.of("apps/main.cpp already exists!")),

            // Generate the BUCK file
            Single.fromCallable(() -> Either.orThrow(BuckFile.generate(projectIdentifier)))
                .flatMapObservable(content -> Observable.concat(
                    CommonTasks.writeFile(
                        content,
                        fs.getPath(projectDirectory.toString(), "BUCK"),
                        false).toObservable()
                        .cast(Event.class)
                        .onErrorReturnItem(Notification.of("BUCK-file already exists!")),
                    Observable.just(Notification.of("buck run :main"))
                ))
        ));
    }
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:72,代码来源:QuickstartTasks.java


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