[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

reading in from a properties file

Posted on 2004-11-11
5
Medium Priority
?
185 Views
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"));
                     inLine.readLine();
                     String location = inLine.readLine();
                     String fileName = processDir(new File(location));
                     System.out.println( "reading from " + location);

where properties.ini contains:

c:\test\mytest\

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.

0
Comment
Question by:imrama
4 Comments
 
LVL 8

Expert Comment

by:kiranhk
ID: 12556196
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

http://mindprod.com/fileio.html

http://www.javaalmanac.com/egs/java.io/pkg.html


http://www.idevelopment.info/data/Programming/java/PROGRAMMING_Java_Programming.shtml




0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12557356
>>giving an array index out of bounds exception

Please post that
0
 
LVL 1

Accepted Solution

by:
pronane earned 200 total points
ID: 12565896
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
0
 

Author Comment

by:imrama
ID: 12584819
ya i used getName() instead and it worked thank you
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

873 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