入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

Android中int,short,long和byte的转换

创建时间:2015-12-23 投稿人: 浏览次数:659
import java.nio.ByteOrder;   public class BytesTransUtils {        private String TAG = "BytesTransUtils";      private static BytesTransUtils instance = null;            private BytesTransUtils() {       // Log.i(TAG, "instance BytesTransUtils");      }            public static BytesTransUtils getInstance() {           if (instance == null) {               instance = new BytesTransUtils();           }                       return instance;      }            public boolean testCPU() {           if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {                // System.out.println("is big ending");                return true;           } else {                // System.out.println("is little ending");                return false;           }      }            public byte[] getBytes(short s, boolean bBigEnding) {           byte[] buf = new byte[2];                       if (bBigEnding){                for (int i = buf.length - 1; i >= 0; i--) {
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
  • 上一篇:没有了
  • 下一篇:没有了
未上传头像