Convert file location to URI and URL

ReturnMethodSummary
URItoURI()Creates a file: URI that represents this abstract pathname.

import java.io.File;

public class Main {

  public static void main(String[] args) {
    File file = new File("c:/a.htm");
    System.out.println(file.toURI());
  }
}

The output:


file:/c:/a.htm
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.