跟着视频写的,有个问题:怎么在SocketClient类中中出现 getData 和sendData 方法是怎么实现的?
private void closeAll() { try { if(socket != null) socket.close(); } catch (IOException e) { e.printStackTrace(); } } private void sendData(CommandTransfer transfer) { try { ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); oos.writeObject(transfer); } catch (IOException e) { e.printStackTrace(); } } private CommandTransfer getData() { CommandTransfer transfer = null; try { ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); transfer = (CommandTransfer) ois.readObject(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return transfer; }
我这边可以运行
我也不知道