title: how to write and read data from smart card using java card apdu
body: <p>I have written an applet and installed it in smart card. But I don't know how to read and write data to smart card?</p>
  
  <pre><code>private void readName(APDU apdu) throws ISOException
  {
      byte[] apduBuffer = apdu.getBuffer();
      for (byte i=0; i&lt;userName.length; i++)
      {
          apduBuffer[5+i] = userName[(byte)i] ;
      }
      apdu.setOutgoing();
      apdu.setOutgoingLength((short)userName.length);
      apdu.sendBytes((short)5, (short)userName.length);
  }
  </code></pre>
  
  <p>Is it right code to read data from smart card?</p>
  
  <p>please tell me how to write data to smart card using javacard.</p>