如何成功调试《Struts在行动》的第一例

作者在 2006-11-14 05:39:00 发布以下内容
struts in action第一例中的两个类
 
UserDirectory.class


package app;

import java.io.IOException;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.util.Enumeration;
import java.util.Properties;
import java.net.URL;



public class UserDirectory  {



    /**
    
    
/
    private static final String UserDirectoryFile =
        "resources/users.properties";

    /**
    
    
/
    private static final String UserDirectoryHeader =
        "${user}=${password}";

    /**
    
    
/
    private static UserDirectory userDirectory = null;

    /**
    
    
/
    private static Properties p;

    /**
    
    
/
    private UserDirectory() throws UserDirectoryException {

            java.io.InputStream i = null;
            p = null;
            i = this.getClass().getClassLoader().
                getResourceAsStream(UserDirectoryFile);

            if (null==i) {
                throw new UserDirectoryException();
            }



            else {



                try {
                    p = new Properties();
                    p.load(i);
                    i.close();
                }



                catch (java.io.IOException e) {
                    p = null;
                    System.out.println(e.getMessage());
 

java | 阅读 903 次
文章评论,共0条
游客请输入验证码