Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at MultiThreadChatClient13.sendFileToServer(MultiThreadChatClient13.java:174)
The only thing that can cause a NullPointerException on that line is if out is null. So it looks like that hasn't been initialised correctly. Did you get any error messages? The way you've written your main() method, it will carry on even if there's an error creating the streams.
I'm a bit dubious about the way your trying to create out, to be honest. Why is it a static variable? And notice that when you finish sendFileToServer you close the stream - that means you won't be able to use it again. It would be better to create a stream when you need it.
(By the way, I've added code tags for you, to make it more readable - see UseCodeTags for details. But it would be even better if your indentation was consistent).
Hi Vaidehi. Can you format any code you post, as I mentioned? Also, you don't need to post that much, just the bits relevant to your problem. Thanks.
I'm going to move this to the networking forum, because the problem isn't really related to Swing and you might get more specific help there. I can't really say what your problem is here, but the first thing I'd be looking to check is that the server is actually running and listening to the address you're connecting to.
Joined: Mar 11, 2013
Thank you so much, I found the problem it is related with IP address.