import java.io.File; public class MainClass { public static void main(String args[]) { try { File testFile = new File("C:\\books\\2004\\test.txt"); System.out.println(testFile.toURI().toString()); } catch (Exception exception) { System.out.println("exception"); } } }