Java tutorial
//package com.java2s; import java.io.File; import java.net.URI; public class Main { /** * 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()); } }