get file URI reference in java

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

Example:

package com.w3spoint;
 
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.

Content Protection by DMCA.com
Please Share