Here you can find the source of getAbsoluteUrlFromFile(final String file)
Converts a file String to a valid URL String.<br> Example: <code>index.html</code> converts to <code>file://C:/path/to/file/index.html</code>.
Parameter | Description |
---|---|
file | the file String |
public static String getAbsoluteUrlFromFile(final String file)
//package com.java2s; //License from project: Apache License import java.net.URL; public class Main { /**// w w w .ja v a 2 s . c om * Converts a file String to a valid URL String.<br> * Example: <code>index.html</code> converts to <code>file://C:/path/to/file/index.html</code>. * * @param file the file String * @return the URL String */ public static String getAbsoluteUrlFromFile(final String file) { if (file == null) { throw new IllegalArgumentException("file must not be null"); } final URL url = ClassLoader.getSystemResource(file); if (url == null) { throw new NullPointerException("url from file=" + file + " is null"); } return url.toString(); } }