/** Finds appropriate FileObjects to java.io.File if possible. * If not possible then empty array is returned. More FileObjects may * correspond to one java.io.File that`s why array is returned. * @param file File whose corresponding FileObjects will be looked for. * The file has to be "normalized" otherwise IllegalArgumentException is thrown. * See {@link #normalizeFile} for how to do that. * @return corresponding FileObjects or empty array if no * corresponding FileObject exists. * @since 1.29 * @deprecated Use {@link #toFileObject} instead. */ @Deprecated public static FileObject[] fromFile(File file) { FileObject[] retVal; if (!file.equals(normalizeFile(file))) { throw new IllegalArgumentException( "Parameter file was not " + // NOI18N "normalized. Was " + toDebugString(file) + " instead of " + toDebugString(normalizeFile(file))); // NOI18N } try { URL url = (Utilities.toURI(file).toURL()); retVal = URLMapper.findFileObjects(url); } catch (MalformedURLException e) { retVal = null; } return retVal; }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); assert fsname != null : "Should always have a non-null fsname here"; FileSystem fs = Repository.getDefault().findFileSystem(fsname); if (fs != null) { assert path != null : "Should always have a non-null path here"; f = fs.findResource(path); } if (f == null) { // Fall back to URL. assert url != null : "Should always have a non-null URL here"; FileObject[] fos = URLMapper.findFileObjects(url); if (fos.length >= 1) { f = fos[0]; } else { throw new FileNotFoundException("Could not restore: " + url); // NOI18N } } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); assert fsname != null : "Should always have a non-null fsname here"; FileSystem fs = Repository.getDefault().findFileSystem(fsname); if (fs != null) { assert path != null : "Should always have a non-null path here"; f = fs.findResource(path); } if (f == null) { // Fall back to URL. assert url != null : "Should always have a non-null URL here"; FileObject[] fos = URLMapper.findFileObjects(url); if (fos.length >= 1) { f = fos[0]; } else { throw new FileNotFoundException("Could not restore: " + url); // NOI18N } } }
/** Finds appropriate FileObjects to java.io.File if possible. * If not possible then empty array is returned. More FileObjects may * correspond to one java.io.File that`s why array is returned. * @param file File whose coresponding FileObjects will be looked for. * The file has to be "normalized" otherwise IllegalArgumentException is thrown. * See {@link #normalizeFile} for how to do that. * @return corresponding FileObjects or empty array if no * corresponding FileObject exists. * @since 1.29 * @deprecated Use {@link #toFileObject} instead. */ public static FileObject[] fromFile(File file) { FileObject[] retVal; if (!file.equals(normalizeFile(file))) { throw new IllegalArgumentException("Parameter file was not " + // NOI18N "normalized. Was " + file + " instead of " + normalizeFile(file)); // NOI18N } try { URL url = (file.toURI().toURL()); if (url.getAuthority() != null && (Utilities.isWindows () || (Utilities.getOperatingSystem () == Utilities.OS_OS2))) { return null; } retVal = URLMapper.findFileObjects(url); } catch (MalformedURLException e) { retVal = null; } return retVal; }
/** Finds appropriate FileObjects to java.io.File if possible. * If not possible then empty array is returned. More FileObjects may * correspond to one java.io.File that`s why array is returned. * @param file File whose coresponding FileObjects will be looked for. * The file has to be "normalized" otherwise IllegalArgumentException is thrown. * See {@link #normalizeFile} for how to do that. * @return corresponding FileObjects or empty array if no * corresponding FileObject exists. * @since 1.29 * @deprecated Use {@link #toFileObject} instead. */ public static FileObject[] fromFile(File file) { FileObject[] retVal; if (!file.equals(normalizeFile(file))) { throw new IllegalArgumentException("Parameter file was not " + // NOI18N "normalized. Was " + file + " instead of " + normalizeFile(file)); // NOI18N } try { URL url = (file.toURI().toURL()); if (url.getAuthority() != null && (Utilities.isWindows () || (Utilities.getOperatingSystem () == Utilities.OS_OS2))) { return null; } retVal = URLMapper.findFileObjects(url); } catch (MalformedURLException e) { retVal = null; } return retVal; }