Java File to URL fileToURL(String filename)

Here you can find the source of fileToURL(String filename)

Description

file To URL

License

BSD License

Declaration

public static URL fileToURL(String filename) 

Method Source Code


//package com.java2s;
//License from project: BSD License 

import java.io.File;

import java.net.MalformedURLException;
import java.net.URL;

public class Main {
    public static URL fileToURL(String filename) {
        try {//from w w w  .  j a v  a 2s  . co  m
            return new File(filename).toURI().toURL();
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. fileToURL(File file)
  2. fileToURL(File file)
  3. fileToURL(File... files)
  4. fileToURL(String file)
  5. fileToURL(String filename)
  6. fileToURLString(File file)