Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By JosAH

Thread: Reading file path IOException (Android, Windows 7)

  1. #1
    Himetic is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Reading file path IOException (Android, Windows 7)

    Whenever I try to create or open a file (using java.io.file) i get an IOexception every single time. I've tried a million different ways to define the path, and no matter what, IOException. I'm using the android interface on windows, and I just want to make a simple text file in the project directory. I've tried to absolute and the relative path, and still gotten the same IOException.

    Sorry, but it's been getting really annoying. I've wasted hours just trying to create a simple file. =/

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: Reading file path IOException (Android, Windows 7)

    Normally those IOExceptions display a reason for the exception: access denied or invalid path name etc. etc.

    kind regards,

    Jos
    Tolls likes this.
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default Re: Reading file path IOException (Android, Windows 7)

    You'll need to give the full error message and stack trace and the relevant bit of code where you're trying to read/write to a file.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    Himetic is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Re: Reading file path IOException (Android, Windows 7)

    here's the trace:

    03-01 19:14:06.790: W/System.err(7145): java.IOException: open Filed: ENOENT (No such file or directory)
    03-01 19:14:06.790: W/System.err(7145): at java.io.File.createNewFile(File.java:940)
    03-01 19:14:06.790: W/System.err(7145): at bvz.bvz.GameView.<init>(GameView.java:78)
    03-01 19:14:06.790: W/System.err(7145): at bvz.bvz.BulletsvsZombiesActivity.onCreate(Bulletsv sZombiesActivity.java:13)
    03-01 19:14:06.790: W/System.err(7145): at android.app.Activity.performCreate(Activity.java:4 465)
    03-01 19:14:06.800: W/System.err(7145): at android.app.Instrumentation.callActivityOnCreate(I nstrumentation.java:1049)
    03-01 19:14:06.800: W/System.err(7145): at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:1920)
    03-01 19:14:06.820: D/dalvikvm(36): GC_EXPLICIT freed <1K, 4% free 9030K/9347K, paused 4ms+4ms
    03-01 19:14:06.820: W/System.err(7145): at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:1981)
    03-01 19:14:06.820: W/System.err(7145): at android.app.ActivityThread.access$600(ActivityThre ad.java:123)
    03-01 19:14:06.830: W/System.err(7145): at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1147)
    03-01 19:14:06.830: W/System.err(7145): at android.os.Handler.dispatchMessage(Handler.java:99 )
    03-01 19:14:06.830: W/System.err(7145): at android.os.Looper.loop(Looper.java:137)
    03-01 19:14:06.830: W/System.err(7145): at android.app.ActivityThread.main(ActivityThread.jav a:4424)
    03-01 19:14:06.830: W/System.err(7145): at java.lang.reflect.Method.invokeNative(Native Method)
    03-01 19:14:06.830: W/System.err(7145): at java.lang.reflect.Method.invoke(Method.java:511)
    03-01 19:14:06.830: W/System.err(7145): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:784)
    03-01 19:14:06.841: W/System.err(7145): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:551)
    03-01 19:14:06.841: W/System.err(7145): at dalvik.system.NativeStart.main(Native Method)
    03-01 19:14:06.841: W/System.err(7145): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
    03-01 19:14:06.850: W/System.err(7145): at libcore.io.Posix.open(Native Method)
    03-01 19:14:06.850: W/System.err(7145): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110 )
    03-01 19:14:06.850: W/System.err(7145): at java.io.File.createNewFile(File.java:933)
    03-01 19:14:06.860: W/System.err(7145): ... 16 more
    03-01 19:14:07.050: D/dalvikvm(36): GC_EXPLICIT freed <1K, 4% free 9030K/9347K, paused 13ms+6ms

    that's basically the same thing I get every time, create or open.

    the code was:


    File f = new File("/Users/Cameron/workspace/BulletsvsZombies", "herkyblerky.txt");
    System.out.println(f.getAbsolutePath());
    try {
    System.out.println(f.createNewFile());
    } catch (IOException e) {
    e.printStackTrace();
    }


    Again, developing for android on Windows 7b in eclipse (indigo).

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Reading file path IOException (Android, Windows 7)

    Moving to the Android section. Please don't post Android questions in New to Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default Re: Reading file path IOException (Android, Windows 7)

    Since your Android code is run on a pseudo-device I suspect that that directory is not visible.
    After all, it wouldn't be visible on your phone.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    Himetic is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Re: Reading file path IOException (Android, Windows 7)

    Quote Originally Posted by Tolls View Post
    Since your Android code is run on a pseudo-device I suspect that that directory is not visible.
    After all, it wouldn't be visible on your phone.
    Hmm, so then how would I set the working directory to something that would be visible? And where should I put the file?

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default Re: Reading file path IOException (Android, Windows 7)

    That I can't answer.
    Really not sure about general interaction with the file system on an Android device.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Reading mapped file MacOSX vs. Windows
    By CapsLoc in forum New To Java
    Replies: 6
    Last Post: 12-12-2010, 07:08 AM
  2. Reading and writing the file in a specified path
    By harsha.udupa2008 in forum New To Java
    Replies: 4
    Last Post: 04-23-2010, 11:48 AM
  3. reading file from a path
    By new_coder in forum New To Java
    Replies: 5
    Last Post: 08-17-2009, 04:52 AM
  4. Weird path problem when reading properties file
    By jerry_popperq in forum New To Java
    Replies: 0
    Last Post: 03-18-2009, 03:32 PM
  5. Replies: 8
    Last Post: 12-01-2008, 02:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •