reading in from a properties file

Posted on 2004-11-11
Last Modified: 2010-03-31
what is wrong with this code, it works fine when i put in the following "." as in the current directory

 inLine = new BufferedReader(new FileReader("properties.ini"));
                     String location = inLine.readLine();
                     String fileName = processDir(new File(location));
                     System.out.println( "reading from " + location);

where properties.ini contains:


it fails on the line String fileName = processDir(new File(location));

giving an array index out of bounds exceptions. but it works fine if i manually put in "." in

  String fileName = processDir(new File(".")); or if i put in the properties.ini file:
 This program has to run on both windows and unix, so solution will have to be platform indepedent.

Question by:imrama
    LVL 8

    Expert Comment

    what is processDir(new File(location)); doing??
    what error are you getting??
    can you post your full code then we can have a look and tell u if anything needs to be changed???

    also you can check out these examples

    LVL 86

    Expert Comment

    >>giving an array index out of bounds exception

    Please post that
    LVL 1

    Accepted Solution

    its a problem with your processDir file, why not use a properties file to read in teh directory.

    Are you sure that whatever the element u are using in the processDir is calling the current files
    .getName() method???  if you are using

    filename.getName();  it will just get the current name of the file in the current directory
    however if you are using
    filename.toString(); it will return the whole path of the file, just something to think about as "."  is the current directory,

    hope that helps

    Author Comment

    ya i used getName() instead and it worked thank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The viewer will learn how to implement Singleton Design Pattern in Java.
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now