UDP/IP Echo Server having problems with data transmission to the server

So I have created a server and client application using a UDP/IP Protocol Suite to communicate. I can get the data to the server but when it arrives and I try to parse the string to an integer I get a NumberFormatException, but when I print the string prior to the format I get what I should which is "8". I posted my code below:

Server

package udp_ip;


import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.io.*;

public class UDPServer {

static private int destport = 9999;
static private int bufsize = 1024;

private DatagramSocket serverSocket;
private InetAddress local_addr;

private UDPServer()
{
    try
    {
        serverSocket = new DatagramSocket(destport);
    }
    catch(IOException ioe)
    {
        System.err.println("Client SOcket could not be created");
    }
    try
    {
        local_addr = InetAddress.getLocalHost();
    }
    catch(Exception uhe)
    {
        System.err.println("Uknown Host:\tLocalHost");
    }
}

private InetAddress getLocalAddress()
{
    return this.local_addr;
}

private DatagramSocket getSocket()
{
    return serverSocket;
}

public static void main(String args[]) throws Exception
{
    UDPServer server = new UDPServer();
    DatagramSocket serverSocket = server.getSocket();
    byte[] acceptData = new byte[bufsize];
    InetAddress local_addr = server.getLocalAddress();

    DatagramPacket receiveTestData = new DatagramPacket (acceptData, 
 acceptData.length);
    serverSocket.receive(receiveTestData);
    String str = new String(receiveTestData.getData());
    System.out.println(str);
    int num = Integer.parseInt(str);
    int result = num*num;

    byte[] testData = (result+"").getBytes();
    DatagramPacket sendPacket = new DatagramPacket(testData, 
 testData.length, local_addr, receiveTestData.getPort());
    serverSocket.send(sendPacket);

     }
   }

Client
package udp_ip;
import java.io.IOException;
import java.net.DatagramPacket;
 import java.net.DatagramSocket;
 import java.net.InetAddress;



public class UDPClient {


static private int destport = 9999;
static private int bufsize = 1024;

private DatagramSocket clientSocket;
private InetAddress local_addr;

private UDPClient()
{
    try
    {
        clientSocket = new DatagramSocket();
    }
    catch(IOException ioe)
    {
        System.err.println("Client Socket could not be created");
    }
    try
    {
        local_addr = InetAddress.getLocalHost();
    }
    catch(Exception uhe)
    {
        System.err.println("Uknown Host:\tLocalHost");
    }
}

private InetAddress getLocalAddress()
{
    return this.local_addr;
}

private DatagramSocket getSocket()
{
    return clientSocket;
}

public static void main(String args[]) throws Exception
{
    UDPClient client = new UDPClient();

    byte[] targetData = new byte[bufsize];
    InetAddress local_addr = client.getLocalAddress();
    int testSend = 8;
    byte[] testTargetData = String.valueOf(testSend).getBytes();

    DatagramPacket testSendPacket = new DatagramPacket(testTargetData, 
    testTargetData.length, local_addr, destport);
    DatagramSocket clientSocket = client.getSocket();
    clientSocket.send(testSendPacket);

    DatagramPacket acceptTargetData = new DatagramPacket(targetData, 
  targetData.length);
    clientSocket.receive(acceptTargetData);

    String str = new String(acceptTargetData.getData());
    System.out.println("Server Sent" + str);
   }
    }

NumberFormatExceptionError