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
  • 298,294
  • 41
  • 291
  • 462
Bhanuprasad
  • 189
  • 7
  • 19

0 Answers0