/** * Get the file path object for the given path. Windows-style '\' is replaced with '/'. * * @param path the path * @return the file path object */ public static FilePath get(String path) { path = path.replace('\\', '/'); int index = path.indexOf(':'); // 如E:\\H2\\tmp\\FileStoreTest\\my.txt // 此时index为1,所以要用FilePathDisk // 而memFS:E:\\H2\\tmp\\FileStoreTest\\my.txt // index是5,所以用FilePathMem registerDefaultProviders(); if (index < 2) { // use the default provider if no prefix or // only a single character (drive name) return defaultProvider.getPath(path); } String scheme = path.substring(0, index); FilePath p = providers.get(scheme); if (p == null) { // provider not found - use the default p = defaultProvider; } return p.getPath(path); }