Update SocketDemo.java

use automatic resource management to close a socket