<pre style="color:rgb(0,0,0); font-family:'宋体'; font-size:11.3pt; background-color:rgb(255,255,255)">
<span style="color:rgb(0,0,128); font-weight:bold">import </span>android.text.TextUtils;
<span style="color:rgb(0,0,128); font-weight:bold">import </span>android.util.Log;
<span style="color:rgb(0,0,128); font-weight:bold">import </span>java.io.File;
<span style="color:rgb(0,0,128); font-weight:bold">import </span>java.io.FileInputStream;
<span style="color:rgb(0,0,128); font-weight:bold">import </span>java.io.FileNotFoundException;
<span style="color:rgb(0,0,128); font-weight:bold">import </span>java.io.IOException;
<span style="color:rgb(0,0,128); font-weight:bold">import </span>java.io.InputStream;
<span style="color:rgb(128,128,128); font-style:italic">/**
</span><span style="color:rgb(128,128,128); font-style:italic"> * Created by snake on 2016/10/11.
</span><span style="color:rgb(128,128,128); font-style:italic"> */
</span><span style="color:rgb(128,128,128); font-style:italic">
</span><span style="color:rgb(0,0,128); font-weight:bold">public class </span>UtilsDataConversion {
<span style="color:rgb(0,0,128); font-weight:bold">private static final </span>String <span style="color:rgb(102,14,122); font-style:italic; font-weight:bold">TAG </span>= <span style="color:rgb(0,128,0); font-weight:bold">"UtilsDataConversion"</span>;
<span style="color:rgb(128,128,128); font-style:italic">//
</span><span style="color:rgb(128,128,128); font-style:italic"> /**
</span><span style="color:rgb(128,128,128); font-style:italic"> * 字节到字符转换
</span><span style="color:rgb(128,128,128); font-style:italic"> *
</span><span style="color:rgb(128,128,128); font-style:italic"> * </span><span style="color:rgb(128,128,128); font-style:italic; font-weight:bold">@param </span><span style="color:rgb(61,61,61); font-style:italic; font-weight:bold">b
</span><span style="color:rgb(61,61,61); font-style:italic; font-weight:bold"> </span><span style="color:rgb(128,128,128); font-style:italic">* </span><span style="color:rgb(128,128,128); font-style:italic; font-weight:bold">@return
</span><span style="color:rgb(128,128,128); font-style:italic; font-weight:bold"> </span><span style="color:rgb(128,128,128); font-style:italic">*/
</span><span style="color:rgb(128,128,128); font-style:italic"> </span><span style="color:rgb(0,0,128); font-weight:bold">public static char </span>getChar(<span style="color:rgb(0,0,128); font-weight:bold">byte</span>[] b, <span style="color:rgb(0,0,128); font-weight:bold">int </span>index) {
<span style="color:rgb(0,0,128); font-weight:bold">int </span>s = <span style="color:rgb(0,0,255)">0</span>;
<span style="color:rgb(0,0,128); font-weight:bold">if </span>(b[index + <span style="color:rgb(0,0,255)">1</span>] > <span style="color:rgb(0,0,255)">0</span>)
s += b[index + <span style="color:rgb(0,0,255)">1</span>];
<span style="color:rgb(0,0,128); font-weight:bold">else
</span><span style="color:rgb(0,0,128); font-weight:bold"> </span>s += <span style="color:rgb(0,0,255)">256 </span>+ b[index + <span style="color:rgb(0,0,255)">0</span>];
s *= <span style="color:rgb(0,0,255)">256</span>;
<span style="color:rgb(0,0,128); font-weight:bold">if </span>(b[index + <span style="color:rgb(0,0,255)">0</span>] > <span style="color:rgb(0,0,255)">0</span>)
s += b[index + <span style="color:rgb(0,0,255)">1</span>];
<span style="color:rgb(0,0,128); font-weight:bold">else
</span><span style="color:rgb(0,0,128); font-weight:bold"> </span>s += <span style="color:rgb(0,0,255)">256 </span>+ b[index + <span style="color:rgb(0,0,255)">0</span>];
<span style="color:rgb(0,0,128); font-weight:bold">char </span>ch = (<span style="color:rgb(0,0,128); font-weight:bold">char</span>) s;
<span style="color:rgb(0,0,128); font-weight:bold">return </span>ch;
}
<span style="color:rgb(128,128,128); font-style:italic">/**
</span><span style="color:rgb(128,128,128); font-style:italic"> * 将一个2个字节数组转换为intt。
</span><span style="color:rgb(128,128,128); font-style:italic"> *
</span><span style="color:rgb(128,128,128); font-style:italic"> * </span><span style="color:rgb(128,128,128); font-style:italic; font-weight:bold">@param </span><span style="color:rgb(61,61,61); font-style:italic; font-weight:bold">b
</span><span style="color:rgb(61,61,61); font-style:italic; font-weight:bold"> </span><span style="color:rgb(128,128,128); font-style:italic">* </span><span style="color:rgb(128,128,128); font-style:italic; font-weight:bold">@return
</span><span style="color:rgb(128,128,128); font-style:italic; font-weight:bold"> </span><span style="color:rgb(128,128,128); font-style:italic">*/
</span><span style="color:rgb(128,128,128); font-style:italic"> </span><span style="color:rgb(0,0,128); font-weight:bold">public static int </span>bytesTwo2Int(<span style="color:rgb(0,0,128); font-weight:bold">byte</span>[] b) {
<span style="color:rgb(0,0,128); font-weight:bold">int </span>a1 = b[<span style="color:rgb(0,0,255)">0</span>] & <span style="color:rgb(0,0,255)">0xff</span>;
<span style="color:rgb(0,0,128); font-weight:bold">int </span>a2 = (b[<span style="color:rgb(0,0,255)">1</span>] & <span style="color: |
|