Questions tagged [filenotfoundexception]

A Java or Android exception that indicates that the file denoted by a specified pathname could not be opened.

This exception is part of the old Java file API. Newer code in Java (note: NOT Android) should use JSR 203 instead (i.e. Paths, Files). JSR 203 (known as NIO.2) has its own java.nio.file.NoSuchFileException, see also .

One problem with this exception is that despite its name, it doesn't always mean that the filesystem object at the given path is actually missing. Here are a few possibilities where this exception can be thrown with a cause other than the file missing:

  • permission denied: an attempt is made to open the file in write mode but the process only has read only access; or the file is in a directory the contents of which the application cannot access;
  • read only filesystem: an attempt is made to open the file in write mode, the process has write access to the file but the underlying filesystem is read only;
  • symbolic link loop: the denoted path is a symbolic link which loops on itself.
1712 questions
14
votes
5 answers

How to handle try catch exception android

I am using a method getBitmap to display images. As I am using this as a method,if it returns bitmap display an image but if it returns null,catch an exception. But if url entered is wrong also, it should handle the FileNotFoundException. How to…
Shadow
  • 6,864
  • 6
  • 44
  • 93
14
votes
3 answers

Detect underlying cause for java.io.FileNotFoundException

FileNotFoundException is thrown on all sorts of occasions - not necessarily only when the file name is invalid, but also when e. g. permissions do not allow a file to be created or read: java.io.FileNotFoundException:…
14
votes
5 answers

FileNotFoundException when loading freemarker template in java

I get a file not found exception while loading a freemarker template even though the template is actually present in the path. Update: This is running as a webservice. It will return an xml to the client based on a search query. The template loads…
jaykumarark
  • 2,359
  • 6
  • 35
  • 53
13
votes
2 answers

FileNotFoundException on Android version > 2.3

I try to download a file to sdcard on my phone. On Android 2.1, 2.2 and 2.3 everything works like intended, but on Android 4.0 (testen on emulator and my Galaxy Nexus) it throws a FileNotFoundException. Stacktrace: 02-27 21:49:06.733:…
Leandros
  • 16,805
  • 9
  • 69
  • 108
13
votes
2 answers

Teamcity not DLL's for some NUnit Test projects

I get this error when running my Moq tests through Teamcity 5 Test(s) failed. System.IO.FileNotFoundException : Could not load file or assembly 'Moq, Version=3.1.416.3, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its…
Dan
  • 12,808
  • 7
  • 45
  • 54
13
votes
3 answers

IntelliJ "FileNotFoundException", File Exists

My objective is to read a text file on IntelliJ. However, when I ran my codes, I get a "FileNotFoundException" message. My file exists. I triple-checked to make sure that the path is correct. I've scoured Stack Overflow looking for an answer, read…
Sugarcoder
  • 167
  • 1
  • 2
  • 10
13
votes
5 answers

StreamReader complains that file does not exist, but it does

I have an application that is localized for use across Europe. I have a menu option that loads a file from disk. This operation works fine on my dev machine but does not work on the virtual machine I use to test other operating systems _ e.g…
Kildareflare
  • 4,590
  • 5
  • 51
  • 65
13
votes
7 answers

Why am I getting a "Could not find a part of the path" exception?

I am developing website using Visual Studio 2010. I am trying to save a file in a path. It works fine localhost. But the same code is not working in IIS. It shows the following error Exception Details: System.IO.DirectoryNotFoundException: Could…
Shashank
  • 6,117
  • 20
  • 51
  • 72
12
votes
4 answers

How to reference a File in raw folder in Android

I just want to create a File object like this File myImageFile = new File ("image1") ; but it is giving me exception of FileNotFoundException How can i reference a file inside my raw Folder EDIT: Actually i wanted to do something like this …
waseemwk
  • 1,499
  • 3
  • 15
  • 44
12
votes
4 answers

java.io.FileNotFoundException, file not being found

I just wanted to read a file line by line. This was meant to be simple, but i just can't get it right! String fileName = "C:/Users/Diogo/Desktop/Krs_Grafo/Graph.txt"; FileReader file = new FileReader(fileName); BufferedReader inputStream = new…
Rauter
  • 521
  • 2
  • 5
  • 16
12
votes
4 answers

FileNotFoundException while running as a jar

FileInputStream fstream = new FileInputStream("abc.txt") is throwing a FileNotFoundExceptionn while running as a jar. Why ? Normally it is able to find while running from main method.
Subhajit
  • 876
  • 3
  • 17
  • 37
11
votes
3 answers

ClickOnce deployment "Activation failed" FileNotFoundException

I just deployed an update to a clickonce application. I have deployed dozens of updates with no issue. Now all of a sudden, with this update, all my users are reporting this error: ERROR SUMMARY Below is a summary of the errors, details of these…
Chris Ray
  • 4,833
  • 2
  • 20
  • 19
11
votes
8 answers

Could not load or assembly or one of its dependencies

I am using Aforge.net frame work for doing image processing work. I have add 'AForge.Video.FFMPEG.dll' as a referance to my project. I am using VS2012 and 32 bit build target. When Buiding i get System.IO.FileNotFoundException was unhandled …
Prathibha Chiranthana
  • 822
  • 1
  • 10
  • 28
11
votes
2 answers

FileNotFound exception when trying to write to a file

OK, I'm feeling like this should be easy but am obviously missing something fundamental to file writing in Java. I have this: File someFile = new File("someDirA/someDirB/someDirC/filename.txt"); and I just want to write to the file. However,…
Chris Knight
  • 24,333
  • 24
  • 88
  • 134
11
votes
4 answers

Android - java.io.FileNotFoundException

when i was inserting the bitmap image to files directory, it showing file not found exception and it is showing Is a Directory. Here is my code: File mFolder = new File(getFilesDir() + "/sample"); if (!mFolder.exists()) { …
srinu_stack
  • 117
  • 1
  • 2
  • 7