我使用StringTokenizer来分隔字符串并读出信息。 我的问题是:第二个循环没有读出最后一个数字。
(这只是一个例子,我的实际项目中存在同样的问题)
输出第一个循环:
69.OK.syncro_asa.1369804.txt ==> 1369804
68.OK.syncro_asa.1346367.txt ==> 1346367
549142.OK.SPB_ASN.1222427.txt ==> 1222427
...
输出第二个循环:
69.syncro_asa.1369804.txt ==> null
68.syncro_asa.1346367.txt ==> null
549142.SPB_ASN.1222427.txt ==> null
...
以上是以下代码的输出:(它是一个JSP-Site)
for (int i = 0;i<infoLogs.countEDI(); i ++)
{
out.println(infoLogs.getEDI(i) +" ==> "+ d_log.getEDInr(i) +" ("+i+")<p>");
}
%>
</p>
</p>
</p>
<%
for (int i = 0;i<info.countEDI(); i ++)
{
out.println(info.getEDI(i) +" ==> "+ d.getEDInr(i) +" ("+i+")<p>");
}
以下方法是importatnt:
class d_log:
public static String getEDInr(int y)
{
String ediNr = stringTeilen(infoLogs.getEDI(y), 4);
return ediNr;
}
class d:
public static String getEDInr(int y)
{
String EDInr = stringTeilen(info.getEDI(y), 3);
return EDInr;
}
两种方法都使用相同的Tokenizer:
public static String stringTeilen(String y, int x)
{
StringTokenizer token = new StringTokenizer(y, ".");
String[] Dateiname = new String[token.countTokens()];
for ( int i=0; i< token.countTokens(); i++ )
{
Dateiname[i] = token.nextToken();
}
return Dateiname[x-1];
}