static FreeDutyProductManager()
{
string fileName = ConfigurationManager.AppSettings["freeDutyProductFile"];
if (!File.Exists(fileName))
{
throw new FileNotFoundException("File can't not find:" +fileName);
}
freeDutyProduct = new Hashtable();
TextReader reader = new StreamReader(File.OpenRead(fileName));
string line = string.Empty;
IList<string> productList = null;
while ((line = reader.ReadLine()) != null)
{
if (line.Trim()== string.Empty)
{
continue;
}
if (line.Trim().EndsWith(":"))
{
productList = new List<string>();
freeDutyProduct.Add(line.Replace(":", ""),productList);
}
else
{
productList.Add(line.Trim());
}
}
}
我想将其转换为 JAVA,但 java 警告我有关哈希表空指针访问:变量 productList 在此位置只能为空。
我能做些什么来解决这个问题?