Java web application that can stream the content of an arbitrary file to the browser (live tail)

半城伤御伤魂 提交于 2019-12-01 09:19:53

问题


I have been searching the web for a while for a Java web application that can be used to "tail" on any arbitrary file on the file system. The most important requirement would be to have the app to stream back the file changes so that I don't have to refresh (like the stuff you can easily do with node.js).

I can quickly write one myself but the streaming requirement is not trivial. Also, the app should be deployable in a Java app server.

Any pointer?

Thanks


回答1:


Ok, so I followed @Liv suggestion and I have built the thing myself. It's the fruit of a couple of hours of coding, so don't expect much.

I have tested it on Tomcat and Jetty. Check out the README file.

https://github.com/aestasit/logviewer




回答2:


I had to do this myself a while back as I couldn't find one. I would recommend going down via the Ajax route -- as trying to have "tail -f ..." process started and capturing its console is tedious and also since you keep the connection to the browser open for a long while you will find out that sometimes the browser will just close the connection.



来源:https://stackoverflow.com/questions/5803776/java-web-application-that-can-stream-the-content-of-an-arbitrary-file-to-the-bro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!