=========Menu Bagian Server========= 1. Start Server 2. server room 2. Exit ============================================= Masukkan Pilihan: masukkan angka! Exception in thread "main" java.util.NoSuchElementException: No line found at java.base/java.util.Scanner.nextLine(Scanner.java:1651) at com.company.Server.menuServer(Server.java:35)
at com.company.Server.main(Server.java:17)
Process finished with exit code 1
here is the code, how to make the menu loop again so i can start the server after it terminated
public static void serverRoom() throws IOException{
din = new DataInputStream(s.getInputStream());
dout = new DataOutputStream(s.getOutputStream());
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
String str = "", str2;
while (!str.equalsIgnoreCase("Exit")) {
str = din.readUTF();
System.out.println("client says: " + str);
str2 = br.readLine();
dout.writeUTF(str2);
dout.flush();
}
din.close();
s.close();
ss.close();
}