I am working on Battleship swing app that communicates through sockets.
private ServerSocket server;
private Socket connection;
private PrintWriter out;
private Scanner in;
out = new PrintWriter(connection.getOutputStream(), true);
in = new Scanner(connection.getInputStream());
public void sendXY(String cord)
public void readHit()
boolean k = true;
if(in.hasNext()) //<--app hangs at this line
Fields.hit = in.nextBoolean();
k = false;
The scanner is waiting for a token, the print method does not send a complete token unless String cord contains some kind of terminator. Try to use println instead.