static函数块中如何调用外部xml参数?

08-04-19 insky

public class StopwordsEnglish extends Stopwords {   
       
    /**  
     *   
     */  
    private static final long serialVersionUID = 1L;   
       
       
    /** The hashtable containing the list of stopwords */  
    private static Hashtable m_Stopwords = null;   
       
       
    static {   
           
        if (m_Stopwords == null) {   
            m_Stopwords = new Hashtable();   
            Double dummy = new Double(0);   
            File txt = new File("data/stopwords/stopwords_en.txt");    
            InputStreamReader is;   
            String sw = null;   
            try {   
                is = new InputStreamReader(new FileInputStream(txt), "UTF-8");   
                BufferedReader br = new BufferedReader(is);                
                while ((sw=br.readLine()) != null)  {   
                    m_Stopwords.put(sw, dummy);      
                }   
            } catch (Exception e) {   
                e.printStackTrace();   
            }   
               
        }   
    }   
       
    /**   
     * Returns true if the given string is a stop word.  
     */  
    public boolean isStopword(String str) {   
           
        return m_Stopwords.containsKey(str.toLowerCase());   
    }   
}  
<p class="indent">


File txt = new File("data/stopwords/stopwords_en.txt"); 这句想传一个参数进去(改下opwords_en.txt的路径) 但是这段在一个static块中,如果改成构造函数的形式需要该太多的相关调用类,这里如果加段读取外部xml配置文件中的参数会不会不好? 大家给点意见如何修改最好 谢谢

猜你喜欢