public void connectionclose() {
   try {
     is.close();
     os.close();
     dis.close();
     dos.close();
     sPort.close();
   } catch (Exception e) {
     System.out.println("close" + e);
   }
 }
コード例 #2
0
  public void read(byte[] data) {
    try {
      is = port.getInputStream();
    } catch (IOException e) {
      System.err.println("IOException: " + e);
    }

    try {
      is.read(data);
    } catch (IOException e) {
      System.err.println("IOException: " + e);
    }
  }
コード例 #3
0
  public void read() throws IOException {
    int i;
    int count = 0;
    byte[] packet = new byte[30];

    while ((i = in.read()) != -1) {
      if (count == 30) {
        System.out.println();
        count = 0;
        listener.packetReceived(packet);
      }
      System.out.print(Hex.toHex(i) + " ");
      packet[count] = (byte) i;
      count++;
    }
  }