| | |
| | | // write("T".getBytes(), "T".length()); |
| | | byte[] read = read(11, 200); |
| | | if (null != read) { |
| | | barcode = new String(read); |
| | | String s = new String(read); |
| | | if (!Cools.isEmpty(s)) { |
| | | barcode = new String(read); |
| | | } |
| | | } |
| | | Thread.sleep(100); |
| | | } catch (SocketTimeoutException ignore) { |
| | |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | public String getBarcode() { |
| | | if (Cools.isEmpty(barcode)) { |
| | | return null; |
| | | } else if("NG".endsWith(barcode)) { |
| | | return null; |
| | | } else { |
| | | return barcode.trim(); |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |