diff --git a/src/main/java/javaSe/netORio/net/web/TcpClient.java b/src/main/java/javaSe/netORio/net/web/TcpClient.java index fb6d75f..7613912 100644 --- a/src/main/java/javaSe/netORio/net/web/TcpClient.java +++ b/src/main/java/javaSe/netORio/net/web/TcpClient.java @@ -14,26 +14,15 @@ public static void main(String[] args) throws Exception { } private static void main0(String[] args) { - Socket s; - try { - s = new Socket(InetAddress.getLocalHost().getHostAddress(), 10002); - } - catch (IOException e) { - throw new RuntimeException(e); - } - try(ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());){ + try(Socket s = new Socket(InetAddress.getLocalHost().getHostAddress(), 10002); + ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());){ + User u = new User("jiumao"); u.setBirthday(new Date()); oos.writeObject(u); }catch (Exception e) { - }finally { - try { - s.close(); - } - catch (IOException e) { - e.printStackTrace(); - } } } } +