[JAVA]int类型和byte[]互转
package com.mapabc.sz_hbt.util;
/**
* <p>Title:整型与长度为4的字节数组的互换 </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2007-5-10</p>
* <p>Company: www.mapabc.com</p>
* @author luoyj
* @version 1.0
*/
public class ByteUtil {
/**
* 整型转换为4位字节数组
* @param intValue
* @return
*/
public static byte[] int2Byte(int intValue) {
byte[] b = new byte[4];
for (int i = 0; i < 4; i++) {
b[i] = (byte) (intValue >> 8 * (3 - i) & 0xFF);
//System.out.print(Integer.toBinaryString(b[i])+" ");
//System.out.print((b[i] & 0xFF) + " ");
}
return b;
}
/**
* 4位字节数组转换为整型
* @param b
* @return
*/
public static int byte2Int(byte[] b) {
int intValue = 0;
// int tempValue = 0xFF;
for (int i = 0; i < b.length; i++) {
intValue += (b[i] & 0xFF) << (8 * (3 - i));
// System.out.print(Integer.toBinaryString(intValue)+" ");
}
return intValue;
}
}
相关文档:
最近成立了一个JAVA 群 想跟大家一块交流 41912406 ; 感觉好久没看过JAVA了 ,都有些生疏了。现在在一家黄金投资公司工作,虽说工作环境还行,但内心里好像并不喜欢这个,以后还是找个软件公司干为好。在这个行业能对世界经济了了解很多,我想这对我以后会有帮助的,先在这干着,长点知识与经验也不错。 ......
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class RunDosCommand {
public static void main(String[] args) throws IOException {
String cmd = "ipconfig";
R ......
各种Java中文转码的例子,用来对付乱码
public class HelloWorld
{
public static void main(String[] argv){
try{
System.out.println("中文1"); //1
System.out.p ......
public class ExcelUtil {
/*
* 根据Excel文件路径和表单名称,一次查找此表单的所有记录*/
public static String[][] getContentByName(String sourcePath,String sheetName){
String[][] strArray = null;
try {
InputStream is = new FileInputStream(sourcePath);
Workbook wb = Workbook.get ......
队列其实 所指生活中排队的现象,去商场购物,付款时需要排队, 买饭时需要排队, 好多事情都是需要排队, 排在第一位的则先处理,结束后, 后面的人都像前移动一位,在开发中也有好多这样的事情需要处理,如文件的下载,短信的发送功能, 等这些都是需要队列方式实现。好了, 废话不多说, 详情见下面代码!
package com. ......