基本上它是一个日志文件阅读器函数,使用其他logreader类及其函数 readLine()和hasMoreLines()我不知道为什么我的while循环不能正常工作 因为它是输出我使用标记器
制作的所有标记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
}
答案 0 :(得分:0)
lr刚刚初始化。我没有看到任何赋值,控件没有进入while循环