readLine()是什么意思?

北渔。 2012-03-09 06:37:09
public String readLine() throws IOException {
return readLine(false);
}

这是类里的,不明白return readLine(false);这句是什么用法哦,谁能帮解释一下?干嘛里面放个false是什么意思?
...全文
830 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
limeng1311 2012-03-10
  • 打赏
  • 举报
回复
也可能是自己写得一个方法吧
superhill 2012-03-10
  • 打赏
  • 举报
回复
API是这样写的

public String readLine()
throws IOException
Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.

Returns:
A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached

这个boolean参数的意思就是,是否忽略换行符,默认为false,也就是不忽略,意思就是读取一行,并且换行
Iver_99 2012-03-10
  • 打赏
  • 举报
回复
只知道BufferReader有个ReadLine是读取一行的意思
-------------------------------------------------------
++
北渔。 2012-03-10
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ldh911 的回复:]

是指BufferedReader吧?
其实是调用了另一个函数:
String readLine(boolean ignoreLF) throws IOException

至于参数false是啥意思,JDK解释的很清楚:
Reads a line of text. A line is considered to be terminated by any one of a line ……
[/Quote]

看不懂这英语啊,哎,“如果为true,下一个回车(\n)会被忽略掉。”这句话是什么意思哦,意思是遇到回车就停止读取?
AlanZhang 2012-03-10
  • 打赏
  • 举报
回复
public String readLine()
throws IOException读取一个文本行。通过下列字符之一即可认为某行已终止:换行 ('\n')、回车 ('\r') 或回车后直接跟着换行。

返回:
包含该行内容的字符串,不包含任何行终止符,如果已到达流末尾,则返回 null
抛出:
IOException - 如果发生 I/O 错误
yousun4688 2012-03-09
  • 打赏
  • 举报
回复
只知道BufferReader有个ReadLine是读取一行的意思
BUG弄潮儿 2012-03-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ldh911 的回复:]
是指BufferedReader吧?
其实是调用了另一个函数:
String readLine(boolean ignoreLF) throws IOException

至于参数false是啥意思,JDK解释的很清楚:
Reads a line of text. A line is considered to be terminated by any one of a line fe……
[/Quote]

这个应该对的,看源码去
MiceRice 2012-03-09
  • 打赏
  • 举报
回复
是指BufferedReader吧?
其实是调用了另一个函数:
String readLine(boolean ignoreLF) throws IOException

至于参数false是啥意思,JDK解释的很清楚:
Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.

@param ignoreLF If true, the next '\n' will be skipped

也就是,如果为true,下一个回车(\n)会被忽略掉。
噢噢噢噢 2012-03-09
  • 打赏
  • 举报
回复
Eclipse里 按住Ctrl 单击readLine(false)
Acesidonu 2012-03-09
  • 打赏
  • 举报
回复
没有源码怎么分析
gameloftyou 2012-03-09
  • 打赏
  • 举报
回复
估计是附近还有个public String readLine(boolean arg){...}方法

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧