Fix MyIO.readLine when reach EOF
This commit is contained in:
parent
9fc9b20dd0
commit
0c40c71008
|
|
@ -172,16 +172,14 @@ class MyIO {
|
|||
|
||||
public static String readLine(){
|
||||
String s = "";
|
||||
char tmp;
|
||||
try{
|
||||
do{
|
||||
char tmp = (char) in.read();
|
||||
while (tmp != '\n' && tmp != (char) -1) {
|
||||
if (tmp != '\r') s += tmp;
|
||||
tmp = (char) in.read();
|
||||
if(tmp != '\n' && tmp != 13){
|
||||
s += tmp;
|
||||
}
|
||||
}while(tmp != '\n');
|
||||
}catch(IOException ioe){
|
||||
System.out.println("lerPalavra: " + ioe.getMessage());
|
||||
System.out.println("MyIO.readLine: " + ioe.getMessage());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue