Taking the Response from the Printer by using Xon and Xoff
<pre><code>how to retrieve the printer response from the Bluetooth printer in android by using X-On and X-Off. I have tried but It is not working. I have tried with the following code but it is not working:

CommPortIdentifier portId  = CommPortIdentifier.getPortIdentifier("COM");
SerialPort sPort = (SerialPort)portId .open(this.getClass().getName(), 30000);
sPort.setSerialPortParams(9600, SerialPort.DATABITS_8,SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
                                            sPort.setFlowControlMode(SerialPort.FLOWCONTROL_XONXOFF_IN | SerialPort.FLOWCONTROL_XONXOFF_OUT);

 OutputStream os = sPort.getOutputStream();
 os=  sPort.getOutputStream();
 InputStream is = sPort.getInputStream(); 
os.write(baos.toByteArray(), 0, baos.toByteArray().length);
 StringBuffer inputBuffer = new StringBuffer();

do{
     for(int newData = is.read();newData != -1; newData = is.read())
      {
        inputBuffer.append((char)newData);
      }

      try
       {
         Thread.sleep(300);
       }
      catch
       {
       }
  }while(inputBuffer.length() &lt;= 0);

String sDataIn = inputBuffer.toString();
</code></pre>

<p>In the above program when the flow comes in the following line it give an error:
CommPortIdentifier portId  = CommPortIdentifier.getPortIdentifier("COM");</p>

<p>Error is::java.lang.ExceptionInInitializerError</p>
