[英]Why does my while loop not work?
基本上它是一个使用其他 logreader 类的日志文件读取器函数,它的函数如 readLine() 和 hasMoreLines() 我不知道为什么我的 while 循环不能正常工作,因为它被假定输出我使用 tokenizer 创建的所有标记
public void readLogFile() throws Exception {
LogReader lr = new LogReader();
LogEntry [] arr = new LogEntry[700];
String logLine;
int count = 0;
System.out.println("OUTSIDE WHILE LOOP"); // for testing
logLine = lr.fileReader.nextLine(); // objct log reader
System.out.println("A DAM LINE IN OUTER LOOP"); // for testing
while (lr.hasMoreLines()) {
StringTokenizer token = new StringTokenizer(lr.readLine());
String date = token.nextToken();
String time = token.nextToken();
String siteName = token.nextToken();
String computerName = token.nextToken();
String sIpAddress = token.nextToken();
String csMethod = token.nextToken();
String csUriStem = token.nextToken();
String csUriQuery = token.nextToken();
String sPort = token.nextToken();
String csUsername = token.nextToken();
String csIpAddress = token.nextToken();
String csVersion = token.nextToken();
String csUserAgent = token.nextToken();
String csCookie = token.nextToken();
String csReferer = token.nextToken();
String csHost = token.nextToken();
String scStatus = token.nextToken();
String scSubStatus = token.nextToken();
String scWin32Status = token.nextToken();
String scBytes = token.nextToken();
String csBytes = token.nextToken();
String timeTaken = token.nextToken();
//基本上它不执行下面的这部分
LogEntry le = new LogEntry(date, time, siteName, computerName,
csMethod, sIpAddress, csUriStem, csUriQuery, sPort,
csUsername, csIpAddress, csVersion, csUserAgent,
csCookie, csReferer, csHost, scStatus, scSubStatus,
scWin32Status, scBytes, csBytes, timeTaken);
arr[count++]=le;
System.out.println(le.toString());
System.out.println("A DAM LINE IN WHILE LOOP"); // for testing
}
lr 刚刚初始化。 我没有看到任何赋值,这个控件没有进入 while 循环
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.