?
Solved

Properties 'load' function

Posted on 2003-03-05
4
Medium Priority
?
220 Views
Last Modified: 2010-03-31
Basically, this code snippet gets to the bit where is says "It gets here 2", what am I doing wrong?

{
  private Properties userInfo;
  private BufferedWriter out;
  private BufferedReader in;
  private MsgSvrConnection conn;

  public void execute() throws IOException
  {
    String sender = conn.getCurrentUser();
    String recipient = in.readLine();
    String content = in.readLine();
    FileInputStream fin = null;
    System.out.println("It gets here 1");
    try{
    fin = new FileInputStream(MsgProtocol.PASSWORD_FILE);
    System.out.println("It gets here 2");
    userInfo.load(fin);
    System.out.println("It gets here 3");
    System.out.println(userInfo.getProperty(recipient)+" recipient");
    }catch(IOException e)
    .............blah blah
0
Comment
Question by:DanJW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Accepted Solution

by:
fivesigmaevent earned 160 total points
ID: 8075213
It looks like from your code, the userInfo is not allocated before you try to invoke its member method.

0
 

Expert Comment

by:fivesigmaevent
ID: 8075244
Please check that it is being allocated elsewhere (which it possibly is) before execute() is called. If so, please disregard my previous comment. :-)
0
 
LVL 9

Expert Comment

by:Venci75
ID: 8078550
>>>
try{
   fin = new FileInputStream(MsgProtocol.PASSWORD_FILE);
   System.out.println("It gets here 2");
   userInfo.load(fin);
   System.out.println("It gets here 3");
   System.out.println(userInfo.getProperty(recipient)+" recipient");
   }catch(IOException e)
   .............blah blah
>>

change the exception handler to:
}catch(Exception e)
e.printStackTrace();
}
and post the exception stack trace
0
 

Author Comment

by:DanJW
ID: 8087245
Ha ha, just shows you how sometimes the simplest things are often overlooked.  I feel ashamed.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

800 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