java.lang.NumberFormatException: multiple points

0

I was trying to read some data through a server, at first fine:

Datagrama recibido del host: /10.166.122.105 desde el puerto remoto: 37547
x=-0.077811554 y=0.094570965 z=9.7324295 grados=0.0
Datagrama recibido del host: /10.166.122.105 desde el puerto remoto: 37547
x=-0.08379706 y=0.09696517 z=9.716867 grados=0.0
...
Datagrama recibido del host: /10.166.122.105 desde el puerto remoto: 37547
x=-0.07182605 y=0.09935937 z=9.701305 grados=0.0.0

So a few lines, until suddenly this message has appeared:

Exception in thread "main" java.lang.NumberFormatException: multiple points
at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
at sun.misc.FloatingDecimal.parseDouble(Unknown Source)
at java.lang.Double.parseDouble(Unknown Source)
at paquete.Servidor.main(Servidor.java:62)

I have searched the internet and it is not clear to me the reason for that exception (since all the information is in English) Could someone explain the reason please? Greetings

PS: I tried using the DecimalFormat class, because I thought it could be because it takes many decimals but it still does not work.

Complete code

    public static void main(String args[]) throws Exception{

    try {
    DatagramSocket socketUDP = new DatagramSocket(puerto);  
    System.out.println("Servidor iniciado");    
    System.out.println("En espera de cliente..."); 

    byte[] receiveData = new byte[1024];

    //Para pasar el byte de String a double
    double x, y, z, grados;
    String xS, yS, zS, gradosS;
    boolean continuar=true;


    while(true) {

            DatagramPacket datosCliente = new DatagramPacket(receiveData, receiveData.length);


            socketUDP.receive(datosCliente);

            System.out.print("Datagrama recibido del host: " + datosCliente.getAddress());
            System.out.println(" desde el puerto remoto: " +datosCliente.getPort());

          contiene el Datagram recibido
            DatagramPacket respuesta = new DatagramPacket(datosCliente.getData(), datosCliente.getLength(), datosCliente.getAddress(), datosCliente.getPort());


            String datosImport = new String( datosCliente.getData());
            System.out.println(datosImport);


       // else{
            String[] a = datosImport.split(" ");
            xS = a[0].substring(a[0].indexOf("=")+1, a[0].length());
            yS = a[1].substring(a[1].indexOf("=")+1, a[1].length());
            zS = a[2].substring(a[2].indexOf("=")+1, a[2].length());
            gradosS = a[3].substring(a[3].indexOf("=")+1, a[3].length());
            x = Double.parseDouble(xS);
            y = Double.parseDouble(yS);
            z = Double.parseDouble(zS);
            grados = Double.parseDouble(gradosS);

    }
     } catch (IOException ex) {
            System.err.println(ex.getMessage());
        }



}
}
    
asked by Antonio 28.02.2018 в 11:54
source

0 answers