Example usage for java.io File toURI

List of usage examples for java.io File toURI

Introduction

In this page you can find the example usage for java.io File toURI.

Prototype

public URI toURI() 

Source Link

Document

Constructs a file: URI that represents this abstract pathname.

Usage

From source file:Main.java

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);
}

From source file:Main.java

  public static void main(String[] argv) throws Exception {
  File file = new File("c:\\");

  URL url = file.toURI().toURL(); 
  URL[] urls = new URL[] { url };

  ClassLoader cl = new URLClassLoader(urls);

  Class cls = cl.loadClass("com.mycompany.MyClass");
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    File file = new File("c:\\");

    URL url = file.toURI().toURL();
    URL[] urls = new URL[] { url };

    ClassLoader cl = new URLClassLoader(urls);

    Class cls = cl.loadClass("com.mycompany.MyClass");
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    File file = new File("filename");

    URI uri = file.toURI();
    file = new File(uri.toURL().getFile());
    InputStream is = uri.toURL().openStream();
    is.close();//from www .j a v a 2s  .co m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    File file = new File("c:\\class\\");
    URL url = file.toURI().toURL();
    URL[] urls = new URL[] { url };
    ClassLoader loader = new URLClassLoader(urls);
    Class cls = loader.loadClass("user.informatin.Class");
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    File file = new File("filename");

    URI uri = file.toURI();
    System.out.println(uri);//  w  w  w .  j  a  va  2 s. com
    file = new File(uri.toURL().getFile());
    InputStream is = uri.toURL().openStream();
    is.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    File f = new File("index.html");
    JEditorPane jep = new JEditorPane(f.toURI().toURL());

    JScrollPane sp = new JScrollPane(jep);
    sp.setPreferredSize(new Dimension(400, 200));

    JOptionPane.showMessageDialog(null, sp);
}

From source file:MainClass.java

public static void main(String args[]) {
    try {//from   w w w  .ja v a  2  s  .com
        File testFile = new File("C:\\books\\2004\\test.txt");
        System.out.println(testFile.toURI().toString());
    } catch (Exception exception) {
        System.out.println("exception");
    }
}

From source file:MediaPlayerDemo.java

public static void main(String args[]) {
    Player player;//from   ww w  .  j  a v a2s .co  m

    File file = new File("yourFile");

    player = Manager.createPlayer(file.toURI().toURL());
    //    player.addControllerListener(new EventHandler());
    player.start(); // start player

    player.close();

    Component visual = player.getVisualComponent();
    Component control = player.getControlPanelComponent();

}

From source file:Main.java

public static void main(String[] args) {
    File f = new File("c:/a/b/a/test.txt");

    // returns the uri string
    URI uri = f.toURI();

    System.out.println("uri: " + uri);

}