Exception in thread main java.nio.file.NoSuchFileException


Exception Stack:
Exception in thread "main" java.nio.file.NoSuchFileException: /Users/c2c/lambdas/sample-file.txt
	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
	at java.base/sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:182)
	at java.base/java.nio.channels.FileChannel.open(FileChannel.java:292)
	at java.base/java.nio.channels.FileChannel.open(FileChannel.java:345)
	at java.base/java.nio.file.Files.lines(Files.java:4038)
	at java.base/java.nio.file.Files.lines(Files.java:4130)
	at JavaFilesWithStreamExample.main(JavaFilesWithStreamExample.java:19)
Reason for NoSuchFileException exception:

The reason for "no such file exception" is either the file that you are trying to process is either missing, misspelled or an incorrect path is provided for the file.

Fix NoSuchFileException exception:

Make sure that,

  • Print the path in the code and check if it is really present,
  • File name provided is correct (check file extension as well)
  • File path (relative/absolute) is provided correctly
  • Check the case of the file name/path
java.nio.file.NoSuchFileException
java.nio.file.NoSuchFileException
Advertisements
Try Out Code2care Dev Tools:

Advertisements



#Android #Java #Linux #Microsoft #Google #Python #MacOS #Notepad++ #Microsoft Teams #CSS #PHP #SharePoint #Html #Linux #C-Program #Bootstrap #jQuery #Sublime #Android-Studio #Facebook #Eclipse #WhatsApp #News #MySQL #Json #HowTos #JavaScript #FTP #S3


Advertisements


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR - https://donate.unhcr.org/in/en-in/ukraine-emergency