We Recommend

Java How to Program Java How to Program
Takes a new tools-based approach to Web application development that uses Netbeans 5.5 and Java Studio Creator 2 to create and consume Web Services. Features new AJAX-enabled, Web applications built with JavaServer Faces (JSF), Java Studio Creator 2 and the Java Blueprints AJAX Components. Includes new topics throughout, such as JDBC 4, SwingWorker for multithreaded GUIs, GroupLayout, Java Desktop Integration Components (JDIC), and much more.


Posted By

javapda on 01/03/08


Tagged


Versions (?)


Convert int to int array of the byte data


Published in: Java 


in Java an int is 4 bytes (32 bits)

  1. int[] getIntBytesFromInt(int base) {
  2. int[] nums = new int[4];
  3. nums[0] = base & 0x000000FF;
  4. nums[1] = (base>>>8) & 0x000000FF;
  5. nums[2] = (base>>>16) & 0x000000FF;
  6. nums[3] = (base>>>24) & 0x000000FF;
  7. return nums;
  8. }

Report this snippet 

You need to login to post a comment.