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.

3
  • Does this question help? Commented Jun 1, 2015 at 9:35
  • Maybe check where the file is put when you package your program. Commented Jun 1, 2015 at 10:01
  • What is "normal java program" ? Commented Jun 1, 2015 at 10:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.