資源簡介
Bitmap類源文件 http://download.csdn.net/detail/ccjjxx001/5049365
用于數據轉換的補充類 大部分源碼來自于網上 自己只有小的修改
代碼片段和文件信息
/*
?*?Copyright?(C)?2013?United?States?Government?as?represented?by?the?Administrator?of?the
?*?National?Aeronautics?and?Space?Administration.
?*?All?Rights?Reserved.
?*/
package?gov.nasa.worldwindx.examples;
/**
*???????
*?Java???Щwindows?????????c??c++??delphi??д????????????????????????????????
*????????????????
*?windows???????????????
*?linuxunix???????????????
*?java?????????仯????????????
??*/
public?class?FormatTransfer
{
/**
??*???int?????????????????????byte????
??*?@param?n?int
??*?@return?byte[]
??*/
public?static?byte[]?toLH(int?n)?{
??byte[]?b?=?new?byte[4];
??b[0]?=?(byte)?(n?&?0xff);
??b[1]?=?(byte)?(n?>>?8?&?0xff);
??b[2]?=?(byte)?(n?>>?16?&?0xff);
??b[3]?=?(byte)?(n?>>?24?&?0xff);
??return?b;
}
/**
??*???int?????????????????????byte????
??*?@param?n?int
??*?@return?byte[]
??*/
public?static?byte[]?toHH(int?n)?{
??byte[]?b?=?new?byte[4];
??b[3]?=?(byte)?(n?&?0xff);
??b[2]?=?(byte)?(n?>>?8?&?0xff);
??b[1]?=?(byte)?(n?>>?16?&?0xff);
??b[0]?=?(byte)?(n?>>?24?&?0xff);
??return?b;
}
/**
??*???short?????????????????????byte????
??*?@param?n?short
??*?@return?byte[]
??*/
public?static?byte[]?toLH(short?n)?{
??byte[]?b?=?new?byte[2];
??b[0]?=?(byte)?(n?&?0xff);
??b[1]?=?(byte)?(n?>>?8?&?0xff);
??return?b;
}
/**
??*???short?????????????????????byte????
??*?@param?n?short
??*?@return?byte[]
??*/
public?static?byte[]?toHH(short?n)?{
??byte[]?b?=?new?byte[2];
??b[1]?=?(byte)?(n?&?0xff);
??b[0]?=?(byte)?(n?>>?8?&?0xff);
??return?b;
}
/**
??*?????int?????????????????????byte????
public?static?byte[]?toHH(int?number)?{
??int?temp?=?number;
??byte[]?b?=?new?byte[4];
??for?(int?i?=?b.length?-?1;?i?>?-1;?i--)?{
????b?=?new?Integer(temp?&?0xff).byteValue();
????temp?=?temp?>>?8;
??}
??return?b;
}
public?static?byte[]?IntToByteArray(int?i)?{
????byte[]?abyte0?=?new?byte[4];
????abyte0[3]?=?(byte)?(0xff?&?i);
????abyte0[2]?=?(byte)?((0xff00?&?i)?>>?8);
????abyte0[1]?=?(byte)?((0xff0000?&?i)?>>?16);
????abyte0[0]?=?(byte)?((0xff000000?&?i)?>>?24);
????return?abyte0;
}
*/
/**
??*???float?????????????????????byte????
??*/
public?static?byte[]?toLH(float?f)?{
??return?toLH(Float.floatToRawIntBits(f));
}
/**
??*???float?????????????????????byte????
??*/
public?static?byte[]?toHH(float?f)?{
??return?toHH(Float.floatToRawIntBits(f));
}
/**
??*???String??byte????
??*/
public?static?byte[]?stringToBytes(String?s?int?length)?{
??while?(s.getBytes().length?????s?+=?“?“;
??}
??return?s.getBytes();
}
/**
??*??????????????String
??*?@param?b?byte[]
??*?@return?String
??*/
public?static?String?bytesToString(byte[]?b)?{
??StringBuffer?result?=?new?StringBuffer(““);
??int?length?=?b.length;
??for?(int?i=0;?i ????result.append((char)(b[i]?&?0xff));
??}
??return?result.toString();
}
/**
??*??????????byte????
??*?@param?s?String
??*?@return?byte[]
??*/
public?static?byte[]?stringToByte
- 上一篇:基于java語言版的銀行信息管理系統
- 下一篇:JAVA題目
評論
共有 條評論