2014-04-12 59 views
-4

基本上它的日志文件阅读器功能使用其他的日志阅读器类和它的功能,如 readLine()和hasMoreLines()我不知道为什么我的while循环不能正常工作 因为它是supossed输出所有令牌,为什么我的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

不工作意味着什么? '输出错误','错误或异常'?什么?如果它的“不正确的输出”,那么什么是未来和预期?如果它的“错误或例外”,张贴那些相关的细节。 – sakura

+0

不正确的输出,只是显示输出行之前while循环需要输出与字符串方法相关的日志文件 –

+0

如果它的'不正确的输出'然后发布什么来了,什么是预期?你可以更新你的问题。 – sakura

回答

0

LR只是初始化。我没有看到它的任何分配,这个控制不进入while循环

相关问题