使用Java New I/O读取行 [英] Read line using Java New I/O

查看:71
本文介绍了使用Java New I/O读取行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用New I/O从文件中读取行的最佳方法是什么?

What's the best way to read a line from a file using the New I/O ?

我一次只能得到一个字节.

I can only get a byte at a time.

有什么主意吗?

推荐答案

BufferedReader 的readline()方法应该足够了.否则,您必须读取任意数量的字节,并分析结尾行'\ n'或\ r \ n'(如果它在Windows样式行结尾)

BufferedReader's readline() method should be enough. Otherwise you have to read an arbitrary number of bytes and parse for the endline '\n' or \r\n' if it is in windows style line ending

这篇关于使用Java New I/O读取行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆