Eclipse控制台输出限制 [英] Eclipse Console Output Limit
问题描述
我正在使用BufferReader从游戏服务器读取日志文件。它确实可以工作,但只是不能读取整个文件的一小部分。
I am using BufferReader to read log files from a game server. It does work but it just doesn't read the entire file just a small portion of it.
我的代码:
public ArrayList<String> readFile(File file){
try (BufferedReader br = new BufferedReader(new FileReader(file.getAbsolutePath())))
{
String sCurrentLine;
ArrayList<String> list = new ArrayList<String>();
while ((sCurrentLine = br.readLine()) != null) {
list.add(sCurrentLine);
}
return list;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
我尝试读取的文件大小在0.5 MB-1.5 MB之间。服务器日志看起来像这样,但是有更多行。像20000行。我只从中得到1500行。
The files that i try to read have the size between 0.5 MB - 1.5 MB. The server logs look like this but it has many more lines. Like 20000 lines. I am only getting like 1500 lines from it.
00:05:29 - Great_Zhupan_Uros_SRB <img=ico_spear> Wolfpack_SikiciArthasan
00:05:32 - Teamhit: AE_Shemaforash hit AB_Artorius for 10 hp.
00:05:32 - AE_Shemaforash <img=ico_axeone> AB_Artorius
00:05:32 - AE_Shemaforash(20578) teamkilled AB_Artorius(1076080).
00:05:41 - Great_Zhupan_Uros_SRB <img=ico_spear> IR_Fall3N~3nG3l
00:05:46 - AE_Shemaforash <img=ico_axeone> Xodanrot
00:06:05 - *DEAD* [AE_Blivandefar] xxxxxxxxxxxxxxxx
00:06:05 - Wolfpack_Dennell has joined the game with ID: 1305305
00:06:07 - Wolfpack_Dennell joined the server.
日志文件的开始时间为00:00:00,结束于23:59:59。当我开始阅读时,它只读取一小部分内容,例如从22:08:00到23:59:59。有人可以告诉我我在做什么错吗?如果对此有更好的解决方案,那我将不胜感激。我使用这些数据将其转换为玩家的统计数据。
The log file starts at time 00:00:00 and ends at 23:59:59. When i start reading it, it only reads a small part of it like from 22:08:00 to 23:59:59. Can someone tell me what i am doing wrong? And if there are better solutions for this then i am all ears. Im using this data to convert them into statistics for players.
推荐答案
复杂的答案似乎是:
-
从文件读取的代码运行正常。
The code for reading from the file is working fine.
如果将从文件中读取的行存储在列表中,然后可能最好的方法是检查列表的大小()。
If you store the lines read from the file in a list then probably the best way to check how many of them were read is to check the size() of the list.
请勿在控制台上打印大量信息(例如1000条以上的行,实际上甚至是100条以上...),因为这样的量可能永远不会被任何人读取。 / p>
Do not print huge amounts of information (like 1000+ lines, or actually even 100+...) to the console, as such amount is probably not to be read by anyone, ever.
这篇关于Eclipse控制台输出限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!