For my project I want to convert an integer into byte array and byte array back to integer
<p>For my project I have to convert an integer into byte array and byte array back to integer.
I did the below code but it is not working</p>

<pre><code>    int temp=200;

    byte[] tempbyte= new byte[4];

String s= String.valueOf(temp);
tempbyte= s.getBytes(); // integer to byte array conversion

String s2 = String.valueOf(ByteBuffer.wrap(tempbyte).getInt());

int temp2 = Integer.parseInt(s2); // byte array to integer conversion

System.out.println("the value of temp2 = "+temp2);
</code></pre>
