Originariamente inviata da EziT90 codice: Scanner sockIN=new Scanner(sock.getInputStream()); String a=sockIN.nextLine(); try{ while(true) { // .... String sockline=sockIN.next(); } ....... Dalle sole parti che ho evidenziato, a parte un primo nextLine(), nel resto del while fai un next(). Questo estrae 1 token. I token in Scanner per default sono separati da whitespace. Se il server manda "Immetti q" questi .... sono DUE token.
Scanner sockIN=new Scanner(sock.getInputStream()); String a=sockIN.nextLine(); try{ while(true) { // .... String sockline=sockIN.next(); } .......
Andrea, andbin.dev – Senior Java developer – SCJP 5 (91%) • SCWCD 5 (94%) java.util.function Interfaces Cheat Sheet — Java Versions Cheat Sheet
Visualizza presentazione tag
Regole del Forum