Coverage Report - com.ctrip.framework.apollo.core.utils.ByteUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
ByteUtil
0%
0/12
0%
0/2
1.2
 
 1  
 package com.ctrip.framework.apollo.core.utils;
 2  
 
 3  
 /**
 4  
  * @author Jason Song(song_s@ctrip.com)
 5  
  */
 6  0
 public class ByteUtil {
 7  0
   private static final char[] HEX_CHARS = new char[] {
 8  
       '0', '1', '2', '3', '4', '5', '6', '7',
 9  
       '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
 10  
 
 11  
   public static byte int3(final int x) {
 12  0
     return (byte) (x >> 24);
 13  
   }
 14  
 
 15  
   public static byte int2(final int x) {
 16  0
     return (byte) (x >> 16);
 17  
   }
 18  
 
 19  
   public static byte int1(final int x) {
 20  0
     return (byte) (x >> 8);
 21  
   }
 22  
 
 23  
   public static byte int0(final int x) {
 24  0
     return (byte) (x);
 25  
   }
 26  
 
 27  
   public static String toHexString(byte[] bytes) {
 28  0
     char[] chars = new char[bytes.length * 2];
 29  0
     int i = 0;
 30  0
     for (byte b : bytes) {
 31  0
       chars[i++] = HEX_CHARS[b >> 4 & 0xF];
 32  0
       chars[i++] = HEX_CHARS[b & 0xF];
 33  
     }
 34  0
     return new String(chars);
 35  
   }
 36  
 }