Find the answer to your Linux question:
Results 1 to 8 of 8
Hi all, I'm trying read a file in "/app/reports/myFile" using java (new File(path)). I'm get a exception java.io.FileNotFoundException, but the file path is correct. File file = new File("/app/reports/myFile"); This ...
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    3

    File path using Java File

    Hi all,

    I'm trying read a file in "/app/reports/myFile" using java (new File(path)).
    I'm get a exception java.io.FileNotFoundException, but the file path is correct.

    File file = new File("/app/reports/myFile");

    This work when I run the applications in windows.
    File file = new File("c:\\reports\\myFile");

    What's wrong ?

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    does the user executing the java application have read access on the file? you should check the permissions of /app, /app/reports, and /app/reports/myFile

  3. #3
    Just Joined!
    Join Date
    Feb 2009
    Posts
    3
    This code is executed with root permissions

  4. #4
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    if ls /app/reports/myFile has results, then I have no idea what your issue is, it should work, especially if the application runs as root

  5. #5
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    Are you sure the constructor is throwing that exception? Can you post your code?

  6. #6
    Just Joined!
    Join Date
    Feb 2009
    Posts
    3
    The problem was the space in the path,

    "/app/reports/myFile "

    Thanks!

  7. #7
    sgb
    sgb is offline
    Just Joined!
    Join Date
    Jul 2011
    Posts
    1
    My problem is similar.

    private static String dataItemDeffileLocation = "/opt/xmetaCMS/xmetaqa/testsuites/commonmetadata_tests/PDR_BaseLine/PSAGRaph/text_exportDataConnectionPSA.xmi";

    getting following exception while accessing the file:
    java.io.FileNotFoundException: /opt/xmetaCMS/xmetaqa/testsuites/commonmetadata_tests/PDR_BaseLine/PSAGRaph/text_exportDataConnectionPSA.xmi (No such file or directory)

    Its having the read access.

    waiting for quick solution please.

    Thanks in Advance.

  8. #8
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,096
    Hello and welcome to the forums, sgb!

    This thread is well over 2 years old so I'm locking it, but do feel free to start a fresh thread of your own if you need any help with Linux.

    Thank you.
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

Posting Permissions

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