Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2010
    Rep Power

    Default how to access a file in the present folder.

    Hi everyone...

    when I am going to use files in one of my programmes.

    I am unable to access the files.

    I am using System.getProperty("user.dir"); statement to get the present location and then using the File object to access it .

    But every time I am getting the message like there is no file .

    I am using netbeans IDE 6.9.

    Can Any body please help me .
    Anantha Nag . KUNDANALA
    ph : 9052012019 , 8143195317

  2. #2
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Pune, India
    Rep Power


    Go through the File IO API documentation.

    That should be enough to guide you how to use files.

    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Rep Power


    If you are trying to access files in the same directory, you can access it with a relative path. For example:

    Java Code:
    BufferedReader in = new BufferedReader(new FileReader(new File("dataFiles/myFile.txt")));
    String line;
            if((line = in.readLine()) == null){
        }catch(Exception e){}
    where datafiles is a folder inside your netbeans project and myFile.txt is a text file inside of that. You do not need the System.getProperty() call to load a local file. If the file is located elsewhere, you can type in the explicit path to the file:
    Java Code:
    ...    new File("/Applications/SomeOtherFolder/dataFiles/myFile.txt") //on *nix systems

Similar Threads

  1. preventing access/locking a folder?
    By solris in forum New To Java
    Replies: 1
    Last Post: 06-29-2009, 12:20 AM
  2. Access Linux shared folder from Windows OS
    By nitinpjairaj in forum Networking
    Replies: 3
    Last Post: 08-26-2008, 06:14 PM
  3. Reading a zip/text file present in a MAC Bundle
    By Prasannaa in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2008, 03:05 PM
  4. How to read a .EML file present on Remote Desktop?
    By anil@prokarma in forum New To Java
    Replies: 0
    Last Post: 06-12-2008, 02:05 PM
  5. how to access shared file/folder in LAN
    By ksheetiz in forum Networking
    Replies: 1
    Last Post: 05-24-2008, 04:54 AM

Posting Permissions

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