Getting a Proper URL from a File Object : File « JDK 6 « Java






Getting a Proper URL from a File Object

 

import java.io.*;
import java.net.*;

public class FileURL {
  public static void main(String args[]) throws MalformedURLException {
    File file = new File("The End");
    URL url2 = file.toURI().toURL();
    System.out.printf("Good url %s%n", url2);
  }
}

        








Related examples in the same category

1.List all roots
2.Get the free space
3.Get the usable space
4.Get the total space
5.File Class Enhancements
6.Creates a file and sets it to read-only.
7.Create a file and change its attribute to readonly