Here you can find the source of filePathToUrl(String filePath)
Parameter | Description |
---|---|
filePath | the absolute path to the file, including drive (i.e., "C:\Program Files...") |
public static String filePathToUrl(String filePath)
//package com.java2s; //License from project: Apache License public class Main { /**//w ww. j a v a2 s .co m * Transforms an absolute file path in the local file system into * a URL-compatible address for the file. * * @param filePath the absolute path to the file, including drive (i.e., "C:\Program Files...") * @return a URL address for the local file */ public static String filePathToUrl(String filePath) { if (filePath.startsWith("/")) { return "file://" + filePath; } else { return "file:///" + filePath; } } }