| | |
| | | String s = new String(read); |
| | | if (!Cools.isEmpty(s)) { |
| | | barcode = new String(read); |
| | | log.info("{}号条码器,检索数据:{}", slave.getId(), this.barcode); |
| | | } |
| | | } |
| | | Thread.sleep(100); |
| | |
| | | public void close() { |
| | | try { |
| | | if (null != dataOutputStream) { |
| | | dataOutputStream.close(); |
| | | } |
| | | if (null != dataInputStream) { |
| | | dataInputStream.close(); |
| | | } |
| | | dataOutputStream.close(); |
| | | } |
| | | if (null != dataInputStream) { |
| | | dataInputStream.close(); |
| | | } |
| | | // if (null != socket && !socket.isClosed()) { |
| | | // socket.close(); |
| | | // } |
| | | if (null != socket){ |
| | | socket.close(); |
| | | } |
| | | socket = null; |
| | | if (null != socket){ |
| | | socket.close(); |
| | | } |
| | | socket = null; |
| | | } catch (IOException e) { |
| | | log.error("SocketClient close Exception:" + e.getMessage()); |
| | | } |
| | |
| | | int len = dataInputStream.read(bytes); |
| | | byte[] tempBytes = null; |
| | | if (len > 0) { |
| | | tempBytes = new byte[len]; |
| | | System.arraycopy(bytes, 0, tempBytes, 0, len); |
| | | tempBytes = new byte[len]; |
| | | System.arraycopy(bytes, 0, tempBytes, 0, len); |
| | | } |
| | | return tempBytes; |
| | | } |