Programming
No. | 315 | ||||
Name. | coolx | ||||
Subject. | tail -f 구현한 소스 | ||||
Main Cate. | JSP/Servlet | ||||
Sub Cate. | |||||
Date. | 2006-07-20 10:39 | ||||
Hit. | 7311 (220.76.115.27) | ||||
File. | |||||
이전 글에 첨부한게 확장자가 jsp 라서 볼수도 없고 다운로드도 안 되서 소스만 따로 올림. <%@ page import='java.io.*' %> <%@ page import='java.util.*' %> <% String line=null; long newlen=0; long length=0; while (true) { RandomAccessFile contents = new RandomAccessFile("/usr/local/apache/logs/club-access_log", "r"); // do whatever with contents newlen=contents.length(); if(length==0) length=newlen; if(newlen>length) { contents.seek(length); while((line=contents.readLine())!=null) { out.println(line+"<br>"); } length=newlen; } // out.println("new length : "+newlen); out.flush(); Thread.sleep(1000); //out.println("before : "+before+"<br>"); if(false) break; } %> [바로가기 링크] : http://coolx.net/cboard/develop/315 |
|||||
|
|||||
[Modify] [Delete] | [Reply] [List] |