Reader如何捕获eof
我对 catch EOF 字符有疑问。
int y = read();
char x = (char) y;
System.out.println(y);
return x;
但是当我得到 EOF 时,它返回 10 并关闭流。我尝试了准备,但它不起作用。 :( 编辑 如何向正在读取 System.in 的程序发出 EOF 信号 NetBeans 控制台? 我将尝试使用 eclipse 控制台,因为其他读者也可以工作。 编辑 问题已解决,可在 eclipse 上使用
I have a problem with the catch EOF character.
int y = read();
char x = (char) y;
System.out.println(y);
return x;
But when I get EOF it returns 10 and closes the stream. I tried with ready, but it doesn't work. :(
EDIT
How do I signal EOF to a program that is reading System.in from the
NetBeans console?
I will try with eclipse console cuz other Readers works.
EDIT
Problem solved works on eclipse
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

Ready() 不会帮助您,因为可以读取流,下一个字符恰好是 EOF。
我不确定你想要做什么,但如果你想防止返回 EOF 字符,你应该添加一个检查。
Ready() won't help you with that since the stream can be read from, the next character just happens to be EOF.
I am not sure what you are looking to do, but if you want to prevent returning the EOF character, you should add a check for it.