一个非常简单的问题,谁能告诉我这个Read()读出的是些什么东西?

CatLuDn 2002-09-10 09:07:29
我想问一下Java.IO下边的*Reader中的Read()方法到底是读出的么东西,越清楚越透彻越好!
谢谢了.
...全文
37 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
CatLuDn 2002-09-10
  • 打赏
  • 举报
回复
没看明白的请看看java的文档,比较一下.net 的文档,你能看出两个写的有么不同吗?但是在读取非法字符时(我是所当前编码中)C#读取合理性竟然比java的好上很多!
CatLuDn 2002-09-10
  • 打赏
  • 举报
回复
这些,我都知道.
来了这么多人,我就顺便问问--它与C#的system.io中的各reader的Read()方法有什么不同,没试过课千万不要做答啊!
原来看来一样的东西会有很多区别的啊!
netstarry 2002-09-10
  • 打赏
  • 举报
回复
什么*reader?
看Returns:
The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached
就知道这个函数返回什么了

namowen 2002-09-10
  • 打赏
  • 举报
回复
返回输入流中当前可用字符的整数表示。如果到达文件结尾,返回-1。
也就是这样了,不知道怎么再详细了。:)
wjmmml 2002-09-10
  • 打赏
  • 举报
回复
read
public int read()
throws IOException
Read a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.
Subclasses that intend to support efficient single-character input should override this method.


Returns:
The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached
Throws:
IOException - If an I/O error occurs

--------------------------------------------------------------------------------

read
public int read(char[] cbuf)
throws IOException
Read characters into an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

Parameters:
cbuf - Destination buffer
Returns:
The number of characters read, or -1 if the end of the stream has been reached
Throws:
IOException - If an I/O error occurs

--------------------------------------------------------------------------------

read
public abstract int read(char[] cbuf,
int off,
int len)
throws IOException
Read characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

Parameters:
cbuf - Destination buffer
off - Offset at which to start storing characters
len - Maximum number of characters to read
Returns:
The number of characters read, or -1 if the end of the stream has been reached
Throws:
IOException - If an I/O error occurs
cat_hangzhou 2002-09-10
  • 打赏
  • 举报
回复
倒,真的是很简单,不会看api啊:(
read
public int read()
throws IOExceptionRead a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.
Subclasses that intend to support efficient single-character input should override this method.

Returns:
The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached
Throws:
IOException - If an I/O error occurs
为什么是*Reader?指的事reader派生出来的类?嘿嘿,那有没有重载就要看不同的类了

62,615

社区成员

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

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