I've got the most random problem. Simply put I look to iterate in a while loop until a certain condition is met and when its not met obviously the code after the loop should be run. For some reason the code after the while loop doesn't run... Here is my code:
while (true)
{
Socket ClientSocketConnection = serverSocket.accept();
System.err.println("We have established a connection with a client!");
System.out.println(" ");
ServerInput = new BufferedReader(new InputStreamReader(ClientSocketConnection.getInputStream()));
ServerOutput = new DataOutputStream(ClientSocketConnection.getOutputStream());
while((StringInput = ServerInput.read()) != -1)
{
//Things get done here
}
//methodBeingUsed is a string here
switch (methodBeingUsed){
case "GET":
GET();
break;
case "POST":
POST(sBuffer.toString());
break;
}
System.err.println("The Connection will now Terminated!");
ServerOutput.close();
ServerInput.close();
ClientSocketConnection.close();
}
}
Basically the switch statement isn't being run for some reason?? When I debugged the code I get to the last -1 from the ServerInput variable the code just stops. Stops and doesn't continue with everything else in the while(true) loop. Really not sure why this is happening...
MethodBeingUsed? What are the possible values it can have?