Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6644379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:09:38+00:00 2026-05-26T00:09:38+00:00

How is it that I only get FileNotFoundException in an android application and when

  • 0

How is it that I only get FileNotFoundException in an android application and when I read it from a normal Java application it finds the directory.

I am using the same code exactly.

{
        BufferedReader bufRdr;
         contacts = new ArrayList<Contacts>();


        File randomContactsFile = new File(("C://test//randomcontacts.txt"));
        try {
         bufRdr = new BufferedReader(new FileReader(randomContactsFile));
    String line = null;
         String[] a = new String[2];

            while ((line = bufRdr.readLine()) != null)
                    {
                        a = line.split(",");
                        Contacts c = new Contacts(a[0], a[1], a[1], a[1], a[2]);
                        contacts.add(c);
                    }

        } catch (FileNotFoundException e) {
            Log.d("file not found", "check");
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

This is the exception:

 10-05 08:04:37.151: WARN/System.err(334):
 java.io.FileNotFoundException: /C:/test/randomcontacts.txt (No such
 file or directory) 10-05 08:04:37.151: WARN/System.err(334):     at
 org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
 10-05 08:04:37.161: WARN/System.err(334):     at
 dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
 10-05 08:04:37.161: WARN/System.err(334):     at
 java.io.FileInputStream.<init>(FileInputStream.java:80) 10-05
 08:04:37.161: WARN/System.err(334):     at
 java.io.FileReader.<init>(FileReader.java:42) 10-05 08:04:37.161:
 WARN/System.err(334):     at
 android.test.randomcontacts.RandomContactsActivity.readRandomContacts(RandomContactsActivity.java:177)
 10-05 08:04:37.161: WARN/System.err(334):     at
 android.test.randomcontacts.RandomContactsActivity.onCreate(RandomContactsActivity.java:55)
 10-05 08:04:37.161: WARN/System.err(334):     at
 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
 10-05 08:04:37.161: WARN/System.err(334):     at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
 10-05 08:04:37.161: WARN/System.err(334):     at
 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
 10-05 08:04:37.161: WARN/System.err(334):     at
 android.app.ActivityThread.access$1500(ActivityThread.java:117)

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:09:39+00:00Added an answer on May 26, 2026 at 12:09 am

    This is this in this part of your code:

    File randomContactsFile = new File(("C://test//randomcontacts.txt"));
    

    C://test//randomcontacts.txt is not in unix path format.

    If your developing for a phone/tablet you should use something like

    /mnt/sdcard/test/randomcontacts.txt

    or better:

    File rootPath=Environment.getExternalStorageDirectory();
    File randomContactsFile = new File(rootPath.getPath()+"/test/randomcontacts.txt");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query statement and want to only get records that has a
I get a BindingFailure on a line of code using the XmlSerializer: XmlSerializer s
I have an Java application for copying large amounts of data from users' workstations
How would you ensure that only one user is logged in per account at
I have a class that only really ever needed by classes in a certain
Compiler error CS0283 indicates that only the basic POD types (as well as strings,
Do you know of any compilers that only requires one or two clicks on
I have had a bug recently that only manifested itself when the library was
Im trying to craft a regex that only returns <link> tag hrefs Why does
I want to create a file that only resides in memory... In looking through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.