大多数表现的方法来解析输入流

发布于 2025-01-27 21:46:53 字数 467 浏览 4 评论 0原文

我想找到解析输入流的最快方法。输入流是动态的,第一行包含所有信息以解析数据。 例如:

key,val
INTEGER,INTEGER
1,5
2,5

为了进行解析,我目前正在使用BufferedReader。我逐行阅读,分开(是分离器),然后分析为开头给出的类型。例如:

BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); 
// ...
String line = reader.readLine();
String[] line = StringUtils.split(stringToSplit, ',');
Integer.parse(line[0]);

我想知道这样做的性能影响是什么,以及我可以做些什么来提高性能?我应该使用字节[]?谢谢 !

I would like to find the fastest way to parse an inputstream. The inputstream is dynamic and the first lines contain all the info to parse the data.
eg:

key,val
INTEGER,INTEGER
1,5
2,5

In order to do the parsing I am currently using a BufferedReader. I read line by line, split on , (which is the separator) and then parse to the type given at the beginning. eg:

BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); 
// ...
String line = reader.readLine();
String[] line = StringUtils.split(stringToSplit, ',');
Integer.parse(line[0]);

I was wondering what is the performance impact of doing that, and what I could do to improve the performance ? Should I use byte[] ? Thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文