< prev index next >
src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java
Print this page
imported patch classloader-cleanup
@@ -28,35 +28,33 @@
import java.net.URL;
import java.io.File;
import sun.net.www.ParseUtil;
/**
- * (Solaris) platform specific handling for file: URLs .
- * urls must not contain a hostname in the authority field
+ * (Unix) platform specific handling for file: URLs .
+ * URLs must not contain a hostname in the authority field
* other than "localhost".
*
* This implementation could be updated to map such URLs
- * on to /net/host/...
+ * on to /net/host/... on system using such an automounter map.
*
* @author Michael McMahon
*/
public class FileURLMapper {
-
- URL url;
+ final URL url;
String path;
- public FileURLMapper (URL url) {
+ public FileURLMapper(URL url) {
this.url = url;
}
/**
* @return the platform specific path corresponding to the URL
* so long as the URL does not contain a hostname in the authority field.
*/
-
- public String getPath () {
+ public String getPath() {
if (path != null) {
return path;
}
String host = url.getHost();
if (host == null || host.isEmpty() || "localhost".equalsIgnoreCase(host)) {
@@ -67,15 +65,10 @@
}
/**
* Checks whether the file identified by the URL exists.
*/
- public boolean exists () {
- String s = getPath ();
- if (s == null) {
- return false;
- } else {
- File f = new File (s);
- return f.exists();
- }
+ public boolean exists() {
+ String s = getPath();
+ return s != null && new File(s).exists();
}
}
< prev index next >