From e084821a98867fde957d67d9cedb4ef4e8d05f66 Mon Sep 17 00:00:00 2001 From: bingor Date: Wed, 19 Oct 2022 09:35:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9D=A6=E5=85=8B=E5=A4=A7=E6=88=98=EF=BC=88?= =?UTF-8?q?=E4=B8=80=E6=9C=9F=EF=BC=89-=E8=AE=BE=E8=AE=A1=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F-=E5=A4=87=E5=BF=98=E5=BD=95=E6=A8=A1=E5=BC=8F1.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/msb/model/GameModel.java | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/msb/model/GameModel.java b/src/main/java/com/msb/model/GameModel.java index ae11f28..5c33e0c 100644 --- a/src/main/java/com/msb/model/GameModel.java +++ b/src/main/java/com/msb/model/GameModel.java @@ -138,10 +138,12 @@ public class GameModel { } catch (IOException e) { e.printStackTrace(); } finally { - try { - oos.close(); - } catch (IOException e) { - e.printStackTrace(); + if(null != oos) { + try { + oos.close(); + } catch (IOException e) { + e.printStackTrace(); + } } } } @@ -156,13 +158,14 @@ public class GameModel { } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); } finally { - try { - ois.close(); - } catch (IOException e) { - e.printStackTrace(); + if(null != ois) { + try { + ois.close(); + } catch (IOException e) { + e.printStackTrace(); + } } } - } }