0
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에서 hashtable에 대해 경고합니다. Null 포인터 액세스 : 변수 productList는이 위치에서만 null 일 수 있습니다.C#에서 Java로 변환
이 문제를 해결하려면 어떻게해야합니까?
Java 코드를 게시해야합니다. – svz
오른쪽. 자바 코드에 문제가있는 경우 해당 코드를 게시하고 문제가 어디에 있는지 설명하십시오. – JHixson