由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 关于 BufferedReader 问题
相关主题
关于char和int的问题Java的中文读写问题
Ask a simple question about throw exception, bow bow bowGUI THANKS
Java basic concept(4)新手请教怎样在Java里读文本文件中的内容
Re: Need Emergent help for Java I/O!大量文本数据的读取
question: how to implement this请教问题,怎么确定空行!
怎么从键盘输入整数或float?再请问版主一个随机读取文件的问题
有人用eclipse吗?如何处理中文文件名?
[转载] smtp server in java?tomcat 快要把我逼疯了, 高手帮忙。
相关话题的讨论汇总
话题: main话题: program话题: separate话题: close
进入Java版参与讨论
1 (共1页)
s***1
发帖数: 49
1
i have a program like this, when the statement "reader.getLine()" in my main
method is run, it gives the error "Stream closed". Why????
I have a function that has a local bufferedreader that I need, and I close
that local reader because it is "cleaner" this way. Then when I return to my
main program, I have a separate bufferedReader, with seperate instantiation
, but the program does not seem to "separate" them? Any explanations? What
should I do to correct it?
public static void main() throws
z***h
发帖数: 405
2
when you hit enter in localFunction, localReader.close() will close your
standard input.
comment it out, it should work.

main
my
instantiation

【在 s***1 的大作中提到】
: i have a program like this, when the statement "reader.getLine()" in my main
: method is run, it gives the error "Stream closed". Why????
: I have a function that has a local bufferedreader that I need, and I close
: that local reader because it is "cleaner" this way. Then when I return to my
: main program, I have a separate bufferedReader, with seperate instantiation
: , but the program does not seem to "separate" them? Any explanations? What
: should I do to correct it?
: public static void main() throws

s***1
发帖数: 49
3
If I don't close it in the localFunction, is it not dangerous?
Also, are you saying if I close the standard input once in a flow of a
program, I can never "re-open" it?

【在 z***h 的大作中提到】
: when you hit enter in localFunction, localReader.close() will close your
: standard input.
: comment it out, it should work.
:
: main
: my
: instantiation

c*****t
发帖数: 1879
4
1. you should not close System.in
2. there is a potential problem using two separate bufferedreader on
the same input stream. You will miss some characters (i.e. buffered
in one reader, and not seen in the other reader).
why don't you just share the buffered reader? the fundamental problem
is your design.

【在 s***1 的大作中提到】
: If I don't close it in the localFunction, is it not dangerous?
: Also, are you saying if I close the standard input once in a flow of a
: program, I can never "re-open" it?

s***1
发帖数: 49
5
ok thanks.

【在 c*****t 的大作中提到】
: 1. you should not close System.in
: 2. there is a potential problem using two separate bufferedreader on
: the same input stream. You will miss some characters (i.e. buffered
: in one reader, and not seen in the other reader).
: why don't you just share the buffered reader? the fundamental problem
: is your design.

1 (共1页)
进入Java版参与讨论
相关主题
tomcat 快要把我逼疯了, 高手帮忙。question: how to implement this
请问同时执行几个bat文件的问题怎么从键盘输入整数或float?
JAVA文本文件读写问题有人用eclipse吗?
how to use grep/sed to remove newlines? (转载)[转载] smtp server in java?
关于char和int的问题Java的中文读写问题
Ask a simple question about throw exception, bow bow bowGUI THANKS
Java basic concept(4)新手请教怎样在Java里读文本文件中的内容
Re: Need Emergent help for Java I/O!大量文本数据的读取
相关话题的讨论汇总
话题: main话题: program话题: separate话题: close