I'm trying to open a file in android like this :
  try    {       FileInputStream fIn = context.openFileInput(FILE);       DataInputStream in = new DataInputStream(fIn);       BufferedReader br = new BufferedReader(new InputStreamReader(in));       if(in!=null)           in.close();    }    catch(Exception e)    {  }   , but in case the file does not exists a file not found exception is thrown . I'd like to know how could I test if the file exists before attempting to open it.
I think the best way to know if a file exists, without actually trying to open it, is as follows:
File file = getContext().getFileStreamPath(FILE_NAME); if(file.exists()) ...   Hope that helps, bye!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With