public String readRfidInformationFromReader() { Socket smtpSocket = null; DataOutputStream os = null; DataInputStream is = null; String s1=""; try { smtpSocket = new Socket("192.168.1.200", 100); os = new DataOutputStream(smtpSocket.getOutputStream()); is = new DataInputStream(smtpSocket.getInputStream()); } catch (UnknownHostException e) { System.err.println("Don't know about host: hostname"); } catch (IOException e) { System.err.println("Couldn't get I/O for the connection to: hostname"); } if (smtpSocket != null && os != null && is != null) { try { byte[] b = new byte[25]; b[0] = 10; b[1] = (byte) 255; b[2] = 2; b[3] = (byte) 128; b[4] = (byte) 117; os.write(b); int i =0; try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } byte n=0; int cnt=0; while (is.available() > 0) { n=is.readByte(); if(i==5) { cnt=(int)n; } i++; } byte[] b1 = new byte[25]; b1[0] = 10; b1[1] = (byte) 255; b1[2] = 3; b1[3] = (byte) 65; b1[4] = (byte) 16; b1[5] = (byte) 163; os.write(b1); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } char[] buffer = new char[1024]; i=0; while (is.available() > 0) { char c = (char) is.readByte(); buffer[i]=c; i++; } int j=0; for(j=0;j0) { s1=buffer[i]+s1; } } s1 =","+s1; } os.close(); is.close(); smtpSocket.close(); } catch (UnknownHostException e) { System.err.println("Trying to connect to unknown host: " + e); } catch (IOException e) { System.err.println("IOException: " + e); } } return s1; }