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


Java FileSystems.getDefault方法代码示例

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


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

示例1: setUp

import java.nio.file.FileSystems; //导入方法依赖的package包/类
@Before
public void setUp() {
    classLoader = new FakeClassLoader();
    fileSupport = new FileSupport() {

        @Override
        public boolean isDirectory(Path path) {
            return true;
        }

        @Override
        public Path getSubDirectory(FileSystem fileSystem, Path root, Path path) throws IOException {
            if (getSubDirectory == null) {
                throw new IOException("Nope");
            }
            return getSubDirectory.apply(root, path);
        }
    };
    target = new ModuleSourceProvider(FileSystems.getDefault(), classLoader, fileSupport);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ModuleSourceProviderTest.java

示例2: testExtractBatchSpreadsheetWithArea

import java.nio.file.FileSystems; //导入方法依赖的package包/类
@Test
public void testExtractBatchSpreadsheetWithArea() throws ParseException, IOException {
    FileSystem fs = FileSystems.getDefault();
    String expectedCsv = UtilsForTesting.loadCsv("src/test/resources/technology/tabula/csv/spreadsheet_no_bounding_frame.csv");
    Path tmpFolder = Files.createTempDirectory("tabula-java-batch-test");
    tmpFolder.toFile().deleteOnExit();

    Path copiedPDF = tmpFolder.resolve(fs.getPath("spreadsheet.pdf"));
    Path sourcePDF = fs.getPath("src/test/resources/technology/tabula/spreadsheet_no_bounding_frame.pdf");
    Files.copy(sourcePDF, copiedPDF);
    copiedPDF.toFile().deleteOnExit();

    this.csvFromCommandLineArgs(new String[]{
            "-b", tmpFolder.toString(),
            "-p", "1", "-a",
            "150.56,58.9,654.7,536.12", "-f",
            "CSV"
    });

    Path csvPath = tmpFolder.resolve(fs.getPath("spreadsheet.csv"));
    assertTrue(csvPath.toFile().exists());
    assertArrayEquals(expectedCsv.getBytes(), Files.readAllBytes(csvPath));
}
 
开发者ID:redmyers,项目名称:484_P7_1-Java,代码行数:24,代码来源:TestCommandLineApp.java

示例3: main

import java.nio.file.FileSystems; //导入方法依赖的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

示例4: getLauncher

import java.nio.file.FileSystems; //导入方法依赖的package包/类
private static String[] getLauncher() throws IOException {
    String platform = getPlatform();
    if (platform == null) {
        return null;
    }

    String launcher = TEST_SRC + File.separator + platform + "-" + ARCH +
                      File.separator + "launcher";

    final FileSystem FS = FileSystems.getDefault();
    Path launcherPath = FS.getPath(launcher);

    final boolean hasLauncher = Files.isRegularFile(launcherPath, LinkOption.NOFOLLOW_LINKS)&&
                                Files.isReadable(launcherPath);
    if (!hasLauncher) {
        System.out.println("Launcher [" + launcher + "] does not exist. Skipping the test.");
        return null;
    }

    // It is impossible to store an executable file in the source control
    // We need to copy the launcher to the working directory
    // and set the executable flag
    Path localLauncherPath = FS.getPath(WORK_DIR, "launcher");
    Files.copy(launcherPath, localLauncherPath,
               StandardCopyOption.REPLACE_EXISTING);
    if (!Files.isExecutable(localLauncherPath)) {
        Set<PosixFilePermission> perms = new HashSet<>(
            Files.getPosixFilePermissions(
                localLauncherPath,
                LinkOption.NOFOLLOW_LINKS
            )
        );
        perms.add(PosixFilePermission.OWNER_EXECUTE);
        Files.setPosixFilePermissions(localLauncherPath, perms);
    }
    return new String[] {launcher, localLauncherPath.toAbsolutePath().toString()};
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:CustomLauncherTest.java

示例5: addPattern

import java.nio.file.FileSystems; //导入方法依赖的package包/类
private static void addPattern(final String fileNameGlobPattern, final List<PathMatcher> matchers) {
    if (fileNameGlobPattern.contains("/")) {
        throw new IllegalArgumentException("cannot contain '/'");
    }
    final FileSystem fs = FileSystems.getDefault();
    final PathMatcher matcher = fs.getPathMatcher(GLOB_SYNTAX + fileNameGlobPattern);
    matchers.add(matcher);
}
 
开发者ID:openweb-nl,项目名称:hippo-groovy-updater,代码行数:9,代码来源:GlobFileNameMatcher.java

示例6: include

import java.nio.file.FileSystems; //导入方法依赖的package包/类
public void include(final String osNameGlobPattern) {
    if (osNameGlobPattern.contains("/")) {
        throw new IllegalArgumentException("OS name pattern cannot contain '/'");
    }

    final FileSystem fs = FileSystems.getDefault();

    final PathMatcher includeOsNames = fs.getPathMatcher(GLOB_SYNTAX + osNameGlobPattern);
    included.add(includeOsNames);
}
 
开发者ID:openweb-nl,项目名称:hippo-groovy-updater,代码行数:11,代码来源:OsNameMatcher.java

示例7: ExplodedImage

import java.nio.file.FileSystems; //导入方法依赖的package包/类
ExplodedImage(Path modulesDir) throws IOException {
    defaultFS = FileSystems.getDefault();
    String str = defaultFS.getSeparator();
    separator = str.equals("/") ? null : str;
    modulesDirAttrs = Files.readAttributes(modulesDir, BasicFileAttributes.class);
    initNodes();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:ExplodedImage.java

示例8: openAndCloseWatcher

import java.nio.file.FileSystems; //导入方法依赖的package包/类
private static void openAndCloseWatcher(Path dir) {
    FileSystem fs = FileSystems.getDefault();
    for (int i = 0; i < ITERATIONS_COUNT; i++) {
        try (WatchService watcher = fs.newWatchService()) {
            dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
        } catch (IOException ioe) {
            // ignore
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:DeleteInterference.java

示例9: createInterceptor

import java.nio.file.FileSystems; //导入方法依赖的package包/类
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
  return new MutantExportInterceptor(FileSystems.getDefault(), params.source(), params.data().getReportDir());
}
 
开发者ID:pitest,项目名称:export-plugin,代码行数:5,代码来源:MutantExportFactory.java

示例10: DirectoryReader

import java.nio.file.FileSystems; //导入方法依赖的package包/类
DirectoryReader(Path path) throws IOException {
    this(FileSystems.getDefault(), path);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:ClassFileReader.java

示例11: GlobPathSet

import java.nio.file.FileSystems; //导入方法依赖的package包/类
public GlobPathSet(final String rootPathString, final String pattern, final FileTreeWalker fileTreeWalker) {
    this(rootPathString, pattern, fileTreeWalker, FileSystems.getDefault());
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:4,代码来源:GlobPathSet.java

示例12: SinglePathSet

import java.nio.file.FileSystems; //导入方法依赖的package包/类
public SinglePathSet(final String path) {
    this(path, FileSystems.getDefault());
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:4,代码来源:SinglePathSet.java

示例13: findAllTests

import java.nio.file.FileSystems; //导入方法依赖的package包/类
static <T> void findAllTests(final List<T> tests, final Set<String> orphans, final TestFactory<T> testFactory) throws Exception {
    final String framework = System.getProperty(TEST_JS_FRAMEWORK);
    final String testList = System.getProperty(TEST_JS_LIST);
    final String failedTestFileName = System.getProperty(TEST_FAILED_LIST_FILE);
    if (failedTestFileName != null) {
        final File failedTestFile = new File(failedTestFileName);
        if (failedTestFile.exists() && failedTestFile.length() > 0L) {
            try (final BufferedReader r = new BufferedReader(new FileReader(failedTestFile))) {
                for (;;) {
                    final String testFileName = r.readLine();
                    if (testFileName == null) {
                        break;
                    }
                    handleOneTest(framework, new File(testFileName).toPath(), tests, orphans, testFactory);
                }
            }
            return;
        }
    }
    if (testList == null || testList.length() == 0) {
        // Run the tests under the test roots dir, selected by the
        // TEST_JS_INCLUDES patterns
        final String testRootsString = System.getProperty(TEST_JS_ROOTS, "test/script");
        if (testRootsString == null || testRootsString.length() == 0) {
            throw new Exception("Error: " + TEST_JS_ROOTS + " must be set");
        }
        final String testRoots[] = testRootsString.split(" ");
        final FileSystem fileSystem = FileSystems.getDefault();
        final Set<String> testExcludeSet = getExcludeSet();
        final Path[] excludePaths = getExcludeDirs();
        for (final String root : testRoots) {
            final Path dir = fileSystem.getPath(root);
            findTests(framework, dir, tests, orphans, excludePaths, testExcludeSet, testFactory);
        }
    } else {
        // TEST_JS_LIST contains a blank speparated list of test file names.
        final String strArray[] = testList.split(" ");
        for (final String ss : strArray) {
            handleOneTest(framework, new File(ss).toPath(), tests, orphans, testFactory);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:TestFinder.java

示例14: fileSystem

import java.nio.file.FileSystems; //导入方法依赖的package包/类
@Override
public FileSystem fileSystem() {
  return FileSystems.getDefault();
}
 
开发者ID:kroepke,项目名称:luna,代码行数:5,代码来源:SystemRuntimeEnvironment.java

示例15: main

import java.nio.file.FileSystems; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    if (args.length < 1) {
        System.err.println("Usage: <picturesRootFolder> [cacheFolder] [configFolder]");
        System.exit(-1);
    }

    FileSystem fileSystem = FileSystems.getDefault();
    Path rootFolder = getRootFolder(fileSystem, args[0]);
    String cacheRootFolder = (args.length >= 2 ? args[1] : "cache");
    String thumbnailCacheFolder = cacheRootFolder + "/thumbnails";
    String fullscreenCacheFolder = cacheRootFolder + "/fullscreen";
    String extractedPicturesCacheFolder = cacheRootFolder + "/extracted";
    String configFile = (args.length >= 3 ? args[2] : ".") + "/photato.ini";

    PhotatoConfig.init(configFile);

    System.out.println("Starting photato");
    System.out.println("-- Config file: " + configFile);
    System.out.println("-- Cache folder: " + cacheRootFolder);
    System.out.println("-- Pictures folder: " + rootFolder);

    HttpServer server = getDefaultServer(fileSystem.getPath("www"));
    server.start();

    if (!Files.exists(fileSystem.getPath("cache"))) {
        Files.createDirectory(fileSystem.getPath("cache"));
    }

    HttpClient httpClient = HttpClientBuilder.create().setUserAgent(serverName).build();

    ExifToolDownloader.run(httpClient, fileSystem, PhotatoConfig.forceFfmpegToolsDownload);
    FfmpegDownloader.run(httpClient, fileSystem, PhotatoConfig.forceExifToolsDownload);

    ThumbnailGenerator thumbnailGenerator = new ThumbnailGenerator(fileSystem, rootFolder, thumbnailCacheFolder, extractedPicturesCacheFolder, PhotatoConfig.thumbnailHeight, PhotatoConfig.thumbnailQuality);
    IGpsCoordinatesDescriptionGetter gpsCoordinatesDescriptionGetter = new OSMGpsCoordinatesDescriptionGetter(httpClient, PhotatoConfig.addressElementsCount);
    MetadataAggregator metadataGetter = new MetadataAggregator(fileSystem, "cache/metadata.cache", gpsCoordinatesDescriptionGetter);
    FullScreenImageGetter fullScreenImageGetter = new FullScreenImageGetter(fileSystem, rootFolder, fullscreenCacheFolder, extractedPicturesCacheFolder, PhotatoConfig.fullScreenPictureQuality, PhotatoConfig.maxFullScreenPictureWitdh, PhotatoConfig.maxFullScreenPictureHeight);

    PhotatoFilesManager photatoFilesManager = new PhotatoFilesManager(rootFolder, fileSystem, metadataGetter, thumbnailGenerator, fullScreenImageGetter, PhotatoConfig.prefixModeOnly, PhotatoConfig.indexFolderName, PhotatoConfig.useParallelPicturesGeneration);

    // Closing tmp server
    server.shutdown(5, TimeUnit.SECONDS);

    while (true) {
        try {
            server = ServerBootstrap.bootstrap()
                    .setListenerPort(PhotatoConfig.serverPort)
                    .setServerInfo(serverName)
                    .setSocketConfig(getSocketConfig())
                    .setExceptionLogger(new StdErrorExceptionLogger())
                    .registerHandler(Routes.rawVideosRootUrl + "/*", new VideoHandler(rootFolder, Routes.rawVideosRootUrl))
                    .registerHandler(Routes.rawPicturesRootUrl + "/*", new ImageHandler(rootFolder, Routes.rawPicturesRootUrl))
                    .registerHandler(Routes.fullScreenPicturesRootUrl + "/*", new ImageHandler(fileSystem.getPath(fullscreenCacheFolder), Routes.fullScreenPicturesRootUrl))
                    .registerHandler(Routes.thumbnailRootUrl + "/*", new ImageHandler(fileSystem.getPath(thumbnailCacheFolder), Routes.thumbnailRootUrl))
                    .registerHandler(Routes.listItemsApiUrl, new FolderListHandler(Routes.listItemsApiUrl, photatoFilesManager))
                    .registerHandler("/img/*", new ImageHandler(fileSystem.getPath("www/img"), "/img"))
                    .registerHandler("/js/*", new JsHandler(fileSystem.getPath("www/js"), "/js"))
                    .registerHandler("/css/*", new CssHandler(fileSystem.getPath("www/css"), "/css"))
                    .registerHandler("*", new DefaultHandler(fileSystem.getPath("www")))
                    .create();
            server.start();
            System.out.println("Server started on port " + server.getLocalPort() + " (http://" + getLocalIp() + ":" + server.getLocalPort() + ")");
            server.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
        } catch (IOException | InterruptedException ex) {
            // In case of port already binded
            System.err.println("Could not start the server ...");
            Thread.sleep(1000);
        }
    }
}
 
开发者ID:trebonius0,项目名称:Photato,代码行数:71,代码来源:Photato.java


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