Here you can find the source of isFileSystemAvailable(final Path file, final String topLevelAbsolutePath)
Parameter | Description |
---|---|
file | a file |
topLevelAbsolutePath | the top-level resource URI for the file. |
static boolean isFileSystemAvailable(final Path file, final String topLevelAbsolutePath)
//package com.java2s; import java.nio.file.Files; import java.nio.file.Path; public class Main { /**//from www . ja v a 2 s. c o m * Determines via best effort if the file system on which the file resides is available. * @param file a file * @param topLevelAbsolutePath the top-level resource URI for the file. * @return true if the file system is available, false otherwise. */ static boolean isFileSystemAvailable(final Path file, final String topLevelAbsolutePath) { if (isEqualPath(file, topLevelAbsolutePath)) { return Files.exists(file); } return isFileSystemAvailable2(file, topLevelAbsolutePath); } private static boolean isEqualPath(final Path file1, final String topLevelAbsolutePath) { return topLevelAbsolutePath.equals(file1.toAbsolutePath() .toString()); } private static boolean isFileSystemAvailable2(final Path file, final String topLevelAbsolutePath) { boolean available; if (Files.exists(file)) { available = true; } else { if (isEqualPath(file, topLevelAbsolutePath)) { available = false; } else { available = isFileSystemAvailable2(file.getParent(), topLevelAbsolutePath); } } return available; } }