Here you can find the source of isFileSystemAvailable(File file, URI topLevelResource)
Parameter | Description |
---|---|
file | a file |
topLevelResource | the top-level resource URI for the file. |
static boolean isFileSystemAvailable(File file, URI topLevelResource)
//package com.java2s; import java.io.File; import java.net.URI; public class Main { /**// w ww. j a v a 2s .co m * Determines via best effort if the file system on which the file resides is available. * @param file a file * @param topLevelResource the top-level resource URI for the file. * @return true if the file system is available, false otherwise. */ static boolean isFileSystemAvailable(File file, URI topLevelResource) { File topLevel = new File(topLevelResource); if (isEqualPath(file, topLevel)) { return file.exists(); } return isFileSystemAvailable(file, topLevel); } private static boolean isFileSystemAvailable(File file, File topLevelResource) { boolean available; if (file.exists()) { available = true; } else { if (isEqualPath(file, topLevelResource)) { available = false; } else { available = isFileSystemAvailable(file.getParentFile(), topLevelResource); } } return available; } private static boolean isEqualPath(File file1, File file2) { return file1.getAbsolutePath().equals(file2.getAbsolutePath()); } }