我试图从客户端接收数据(以未知格式发送的数据)。 我收到的数据有很多空格,例如: 客户端发送我在服务器1中获得的数字1.50。 5 0, 我该如何将它转换为普通的双背?
int port = 1245;
ServerSocket serverSocket = new ServerSocket(port);
try {
while(true)
{
//Reading the message from the client
socket = serverSocket.accept();
InputStream is = socket.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String number = br.readLine();
console.getOut().println(number);
//Multiplying the number by 2 and forming the return message
String returnMessage;
}
}
catch(Exception e) {
console.getOut().println("Whoops! It didn't work!\n");
}
}
catch(Exception e) {
console.getOut().println("Whoops! It didn't work!\n");
}