Tutorialspoint examples

Learn java tutorial with examples for beginners online

get file uri reference in java program


The toURI() method of File class is used to get the URI reference.

Example:

package com.tutorialspointexamples;
 
import java.io.File;
 
public class FileURI {
  public static void main(String args[]){
	  File file = new File("D:/Test files/file 3.txt");
	  System.out.println(file.toURI());
  }
}

Output:

file:/D:/Test%20files/file%203.txt

Download this example.

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status