Here is the piece of code which I think is causing the problem.
while((is.read(bytes)) != -1)
{
fos.write(bytes);
}
JOptionPane.showMessageDialog(null,"File Received.","Complete.",JOptionPane.INFORMATION_MESSAGE);
//System.out.println("File Received.");
Now when the control comes to the JOptionPane statement nothing shows up and the program won't even ends up. I had to end it from the task manager manually. When I tried commenting out the JOptionPane statement and used the console method i.e. System.out.println() to show the message it worked and the program ended normally. I don't understand why this JOptionPane is causing this problem. I am stuck here. Help would be appreciated. Thanks in anticipation.