java.io.IOException The system cannot find the path specified

If you are trying to write content into file and getting exception similar shown below:

java.io.IOException: The system cannot find the path specified
	at java.io.WinNTFileSystem.createFileExclusively(Native Method)
	at java.io.File.createNewFile(File.java:883)
	at com.javahonk.transienttest.TransientTest.main(TransientTest.java:25)
Exception in thread "main" java.lang.NullPointerException
	at com.javahonk.transienttest.TransientTest.main(TransientTest.java:53)

 

Solution: This exception thrown if java don’t find specified folder/file as example shown below:

File file = new File("C:\\JavaHonk\\Test.txt");

In my case folder name : JavaHonk wasn’t exits so it was throwing exception. Manually I created folder in C: drive and ran program again without any issue.

2 thoughts on “java.io.IOException The system cannot find the path specified”

Leave a Reply

Your email address will not be published. Required fields are marked *