Fix MyIO.readLine when reach EOF

This commit is contained in:
axell-brendow 2020-11-12 15:40:04 -03:00
parent 9fc9b20dd0
commit 0c40c71008
1 changed files with 6 additions and 8 deletions

View File

@ -172,16 +172,14 @@ class MyIO {
public static String readLine(){ public static String readLine(){
String s = ""; String s = "";
char tmp;
try{ try{
do{ char tmp = (char) in.read();
tmp = (char)in.read(); while (tmp != '\n' && tmp != (char) -1) {
if(tmp != '\n' && tmp != 13){ if (tmp != '\r') s += tmp;
s += tmp; tmp = (char) in.read();
} }
}while(tmp != '\n');
}catch(IOException ioe){ }catch(IOException ioe){
System.out.println("lerPalavra: " + ioe.getMessage()); System.out.println("MyIO.readLine: " + ioe.getMessage());
} }
return s; return s;
} }