I'm trying to build a program that uses sockets and connections to connect to the internet. Right now, I use a PrintWriter to send messages out, but I don't like using it? Is there any other alternative to PrintWriter? I don't like the idea of having to flush() when I want the message to send and it seems to lose the connection after i flush() it the first time. Is there any way to stop this or something better to use to send outgoing messages? Thanks for any help in advance.

-Nick Nisi

Well, there is the PrintStream class, but I would use the PrintWriter. Actually, if you want automatic flushing, then PrintStream would probably be better. If you want to stick with the PrintWriter, try calling the flush after a print() method, and make sure you are closing the connection after it is sent. You don't really need to close the connection, but you DO need to make sure you are calling the flush method AFTER the print statement.