0

I am working on spring ,I want to read file name from a jar file,But I am getting FileNotFoundException. Any one help me, please check my code below.

 ClassPathResource classPathResource =  new ClassPathResource("test.txt");
   System.out.println(classPathResource.getPath());
    System.out.println(classPathResource.getURI());
    System.out.println(classPathResource.getURL().getPath());
    System.out.println(classPathResource.getURI().getPath());

but when I wrote like below

System.out.println(classPathResource.getFile().getCanonicalPath());
System.out.println(classPathResource.getFile().getPath());

the above two lines are throwing exception, but when I am working with normal java program, everything is working great.

user207421
  • 305,947
  • 44
  • 307
  • 483
Bhanuprasad
  • 229
  • 8
  • 20

0 Answers0