java.lang.NumberFormatException

this my code

import java.io.*;

import java.net.*;

import java.*;

class UDPServer

{

publicstaticvoid main(String args[])throws Exception

{

UDPServer t =new UDPServer();

DatagramSocket serverSocket =new DatagramSocket(5551);

while(true)

{

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

serverSocket.receive(receivePacket);

String sentence =new String(receivePacket.getData());

for (i=0;i<sentence.length();i=i+2){

char letter1= sentence.charAt(i);

String u = h.valueOf(letter1);

time = (Integer.parseInt(u));

char letter2= sentence.charAt(i+1)

char letter3= sentence.charAt(i+2);

u2 = h.valueOf(letter2);

//try{

time2 = (Integer.parseInt(u2));

// }catch(NumberFormatException ex){System.err.println("error2");}

time = 1000*(10*time+time2);

i++;

if (letter3==('F')){

System.out.println ("this is F");

//p5.write(240);

try{

Thread.sleep(time);

}

catch (InterruptedException ie){}

//p5.write(0); // To stop after the movement

}

//

elseif (letter3==('B'))

{

System.out.println ("This is B");

//p5.write(160);

try

{

Thread.sleep(time);

}

catch (InterruptedException ie){}

//p5.write(0); // To stop after the movement

}

//--

elseif (letter3==('L'))

{

// p5.write(192);

System.out.println ("This is L");

try

{

Thread.sleep(time);

}

catch (InterruptedException ie){}

//p5.write(0); // To stop after the movement

}

//

elseif (letter3==('R'))

{

// p5.write(48);

System.out.println ("This is R");

try

{

Thread.sleep(time);

}

catch (InterruptedException ie){}

//p5.write(0); // To stop after the movement

}

//-

elseif (letter3==('S'))

{

// p5.write(0);

System.out.println ("This is S");

try

{

Thread.sleep(0);

}

catch (InterruptedException ie){}

}

}

}

}

}

when I send the input "12F" the following client program

import java.io.*;

import java.net.*;

class UDPClient{

publicstaticvoid main(String args[])throws Exception

{

boolean send =true;

BufferedReader inFromUser =new BufferedReader(new InputStreamReader(System.in));

DatagramSocket clientSocket =new DatagramSocket();

InetAddress IPAddress = InetAddress.getByName("coe-347B-Fac");

byte[] sendData =newbyte[1024];

byte[] receiveData =newbyte[1024];

while(send){

System.out.println (" Please Enter String You Want to Send : " );

String sentence = inFromUser.readLine();

sendData = sentence.getBytes();

DatagramPacket sendPacket =

new DatagramPacket(sendData, sendData.length, IPAddress, 5551);

clientSocket.send(sendPacket);

}

clientSocket.close();

}

}

after execution this input it exit and do not take onther input. it give me this output

******************************

this is F

Exception in thread "main" java.lang.NumberFormatException: For input string: "

"

at java.lang.NumberFormatException.forInputString(NumberFormatException.

java:48)

at java.lang.Integer.parseInt(Integer.java:447)

at java.lang.Integer.parseInt(Integer.java:497)

at UDPServer.main(UDPServer.java:51)

***********************************************

So what is the problem?>

[7530 byte] By [NetWorriera] at [2007-10-2 20:02:51]
# 1
The code you posted is not what you are running - it won't compile. What is the 'h' variable?The error occurs when the String 'sentence' contains characters that can not be converted to an int. I am just guessing, but a line like this may help.[code]sentence = sentence.trim();
atmguya at 2007-7-13 22:42:48 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...