title: Convert int to hex byte value
body: <p>I want to read block wise data of NFC tag. For which the command is a byte array and it needs block number.</p>
  
  <pre><code>public static byte[] readSingleBlockCmd(int blockNo) {
          byte[] cmd = new byte[3];
          cmd[0] = (byte) 0x02;//flag
          cmd[1] = (byte) 0x23;//cmd
          cmd[2]= (byte)blockNo;
  
          return cmd;
  
      }
  </code></pre>
  
  <blockquote>
    <ul>
    <li>How can I change the int blockNo to its hexadecimal value , which can be cast to byte .I want the byte value and not an byte []</li>
    </ul>
  </blockquote>
  
  <p>I have gone through the following links</p>
  
  <p><a href="https://stackoverflow.com/questions/1936857/convert-integer-into-byte-array-java">Convert integer into byte array (Java)</a></p>
  
  <p><a href="https://stackoverflow.com/questions/9616233/how-to-autoconvert-hexcode-to-use-it-as-byte-in-java">How to autoconvert hexcode to use it as byte[] in Java?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2183240/java-integer-to-byte-array">Java integer to byte array</a></p>
  
  <p>Thanks!</p>