- 浏览: 830788 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (379)
- struts (5)
- hibernate (16)
- spring (16)
- ssh (20)
- MySQL (16)
- 数据库脚本 (2)
- DownLoad (1)
- GAE (5)
- Java (103)
- LoadRunner (2)
- VF (1)
- 学习资料 (24)
- 软件使用 (21)
- 通信类 (4)
- 生活 (3)
- J2ME (1)
- 心理学 (1)
- Linux (26)
- Android (3)
- Oracle (1)
- 面向对象概念&面试准备 (11)
- ExtJs (2)
- Google Map (1)
- Flex (47)
- 算法研究 (1)
- share (20)
- python (1)
- MongoDB (7)
- centos6 (13)
- C++ (8)
- DB2 (3)
- C# (1)
- 代码片段 (24)
- Lucene (2)
- php (1)
- NodeJS (1)
- Express (1)
最新评论
-
shua1991:
已阅,我表示同意。
Eclipse统计代码行数 -
nakedou:
写的不错,挺详细的
在CentOS中使用 yum 安装MongoDB及服务器端配置 -
sjp524617477:
好方法
Eclipse统计代码行数 -
simpletrc:
<script>ale ...
Java写到.txt文件,如何实现换行 -
csdn_zuoqiang:
Apache Ftp Server,目前是1.0.4,非常好的 ...
Apache FtpServer在64位系统下服务不能启动解决方法
/** * 各基础类型与byte之间的转换 * @author shanl * */ public class Utility { /** * 将short转成byte[2] * @param a * @return */ public static byte[] short2Byte(short a){ byte[] b = new byte[2]; b[0] = (byte) (a >> 8); b[1] = (byte) (a); return b; } /** * 将short转成byte[2] * @param a * @param b * @param offset b中的偏移量 */ public static void short2Byte(short a, byte[] b, int offset){ b[offset] = (byte) (a >> 8); b[offset+1] = (byte) (a); } /** * 将byte[2]转换成short * @param b * @return */ public static short byte2Short(byte[] b){ return (short) (((b[0] & 0xff) << 8) | (b[1] & 0xff)); } /** * 将byte[2]转换成short * @param b * @param offset * @return */ public static short byte2Short(byte[] b, int offset){ return (short) (((b[offset] & 0xff) << 8) | (b[offset+1] & 0xff)); } /** * long转byte[8] * * @param a * @param b * @param offset * b的偏移量 */ public static void long2Byte(long a, byte[] b, int offset) { b[offset + 0] = (byte) (a >> 56); b[offset + 1] = (byte) (a >> 48); b[offset + 2] = (byte) (a >> 40); b[offset + 3] = (byte) (a >> 32); b[offset + 4] = (byte) (a >> 24); b[offset + 5] = (byte) (a >> 16); b[offset + 6] = (byte) (a >> 8); b[offset + 7] = (byte) (a); } /** * byte[8]转long * * @param b * @param offset * b的偏移量 * @return */ public static long byte2Long(byte[] b, int offset) { return ((((long) b[offset + 0] & 0xff) << 56) | (((long) b[offset + 1] & 0xff) << 48) | (((long) b[offset + 2] & 0xff) << 40) | (((long) b[offset + 3] & 0xff) << 32) | (((long) b[offset + 4] & 0xff) << 24) | (((long) b[offset + 5] & 0xff) << 16) | (((long) b[offset + 6] & 0xff) << 8) | (((long) b[offset + 7] & 0xff) << 0)); } /** * byte[8]转long * * @param b * @return */ public static long byte2Long(byte[] b) { return ((b[0]&0xff)<<56)| ((b[1]&0xff)<<48)| ((b[2]&0xff)<<40)| ((b[3]&0xff)<<32)| ((b[4]&0xff)<<24)| ((b[5]&0xff)<<16)| ((b[6]&0xff)<<8)| (b[7]&0xff); } /** * long转byte[8] * * @param a * @return */ public static byte[] long2Byte(long a) { byte[] b = new byte[4 * 2]; b[0] = (byte) (a >> 56); b[1] = (byte) (a >> 48); b[2] = (byte) (a >> 40); b[3] = (byte) (a >> 32); b[4] = (byte) (a >> 24); b[5] = (byte) (a >> 16); b[6] = (byte) (a >> 8); b[7] = (byte) (a >> 0); return b; } /** * byte数组转int * * @param b * @return */ public static int byte2Int(byte[] b) { return ((b[0] & 0xff) << 24) | ((b[1] & 0xff) << 16) | ((b[2] & 0xff) << 8) | (b[3] & 0xff); } /** * byte数组转int * * @param b * @param offset * @return */ public static int byte2Int(byte[] b, int offset) { return ((b[offset++] & 0xff) << 24) | ((b[offset++] & 0xff) << 16) | ((b[offset++] & 0xff) << 8) | (b[offset++] & 0xff); } /** * int转byte数组 * * @param a * @return */ public static byte[] int2Byte(int a) { byte[] b = new byte[4]; b[0] = (byte) (a >> 24); b[1] = (byte) (a >> 16); b[2] = (byte) (a >> 8); b[3] = (byte) (a); return b; } /** * int转byte数组 * * @param a * @param b * @param offset * @return */ public static void int2Byte(int a, byte[] b, int offset) { b[offset++] = (byte) (a >> 24); b[offset++] = (byte) (a >> 16); b[offset++] = (byte) (a >> 8); b[offset++] = (byte) (a); } }
评论
1 楼
csdn_zuoqiang
2012-05-31
public class FileHead { /**版本*/ public static final int VERSION = 0x00000001; /**头标志*/ public static final byte[] FLAG = {'T', 'E', 'S', 'T'}; /**压缩算法*/ public int compress = 0x00000003; } //向文件中写头信息 static void t6(){ FileHead head = new FileHead(); OutputStream out = null; head.compress = 0x04; out.write(Utility.int2Byte(head.VERSION)); out.write(head.FLAG); out.write(Utility.int2Byte(head.compress)); }
发表评论
-
微信JS
2013-10-26 21:17 2039<div class="iteye-blog- ... -
ubuntu下MySQL用source命令导入sql文件出现乱码解决方法
2012-11-18 23:46 1483首先建立数据库的时候指明数据库编码如: CREA ... -
RandomAccessFile
2012-10-18 18:16 941public void run() { try { ... -
java中多种方式读文件
2012-10-18 16:53 923java中多种方式读文件一、多种方式读文件内容。1、按字节读取 ... -
FileChannelMain
2012-10-15 18:12 1072package scan; import java ... -
IDEA 常用配置以及快捷
2012-09-01 10:38 50921. IDEA内存优化 ... -
Ubuntu 10.04 TinyOS
2012-08-20 00:42 1544sudo gedit /etc/apt/sources.lis ... -
我看用户体验与用户价值
2012-07-01 14:55 1031不知道从什么时候开始,各个信息源都开始充斥着用户体验的讨 ... -
在windows 7上安装Maven2.2.1
2012-06-18 17:00 1215Maven是一个java工具,所以请确保jdk环境已经正确安装 ... -
产品经理如何赢得开发人员的尊重和支持?
2012-06-14 09:08 945对于产品经理来说, ... -
Apache FtpServer在64位系统下服务不能启动解决方法
2012-06-10 21:29 6799Apache FTPServer是一款用Java开发的 ... -
Java 集合类
2012-06-07 22:03 1563Java 集合类 1. 为什么要了解J ... -
Java集合工具类之List - ArrayList & LinkedList
2012-06-07 21:21 18981.ArrayList 的数据结构 ... -
VISIO2010 密钥
2012-06-07 08:35 6vISIO PREMIUM GR24B-G ... -
网络爬虫调研报告
2012-06-06 11:17 6008网络爬虫调研报告 调研背景 项目中要对 ... -
海量数据处理
2012-06-05 10:02 1867一:常见的题目:- 1 ... -
新浪/搜狐微博插件 for Gwibber 3.0
2012-05-28 14:02 1756通过 Ubuntu 的 Gwibber 组件,我们可以很 ... -
Ubuntu 12.04 改造指南
2012-05-28 10:47 1399升级12.04已经有一段时间了。作为一个从08年就开始用 ... -
使用apt-get方式为Linux Mint 13安装PHP+MYSQL+Apache
2012-05-25 17:48 4765使用apt-get方式为Ubuntu安装PHP+MYSQ ... -
Linux Mint 13 配置JAVA 环境
2012-05-24 22:35 26190.1--下载 JAVA ...
相关推荐
下面小编就为大家带来一篇java byte数组与int,long,short,byte的转换实现方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
举例分析 equals 和 hashcode 方法,hashcode应该怎么样生成 8个基本类型与基本对象的比较:byte与Byte shot与Short int与Integer long与Long float与Float double与Double char与Character
char short int long float double 转换成byte数组
一些工具类代码块的标准代码,包括但不限于: 十六进制字符串转换为byte数组 char转换为byte数组 16进制转化为数字 ytes数组转16进制String byte数组转换为十六进制字符串 int转换为byte数组 byte数组转换为int 保留...
ip地址转4字节byte,char转2字节byte,byte数组转char,int整数转换为4字节的byte数组,byte数组转换为int整数,double类型转8字节数组,8位数组转double,long整数转换为8字节的byte数组,short整数转换为2字节的...
在switch(expr1)中,expr1只能是一个整数表达式或者枚举常量(更大字体),整数表达式可以是int基本类型或Integer包装类型,由于,byte,short,char都可以隐含转换为int,所以,这些类型以及这些类型的包装类型也...
byte→short(char)→int→long→float→double 也就是说byte类型的变量可以自动转换为short类型,示例代码: byte b = 10; short sh = b; 这里在赋值时,JVM首先将b的值转换为short类型,然后再赋值给sh。 在类型...
在java中的整数类型有四种,分别是byte short in long,本文重点给大家介绍java中的整数类型(short int long),由于byte只是一个字节0或1,在此就不多说了,对java中的整数类型感兴趣的朋友一起学习吧
一些初学JAVA的朋友可能会遇到JAVA的数据类型之间转换的苦恼,例如,整数和float,double型之间的转换,整数和String类型之间的转换,以及处理、显示时间方面的问...byte、short、int、long;浮点型float、double。其
[signed] short [int] 2Byte unsigned short [int] 2 Byte long [int] 4 Byte unsigned long [int] 4 Byte Visual C++ 6.0: [signed] int 4Byte unsigned int 4Byte [signed] short [in
byte→short(char)→int→long→float→double 也就是说byte类型的变量可以自动转换为short类型,示例代码: byte b = 10; short sh = b; 在类型转换时可以跳跃。示例代码: byte b1 = 100; int n = b1; ...
int HufBlock(BYTE dchufindex,BYTE achufindex); int DecodeElement(); BYTE ReadByte(); int WaterMarkExtractDecode(); void IQtIZzMCUComponent(short flag); void IZzMCUComponent(short flag); void ...
byte short int long 的关系
Java Number类提供了以下基本的数字操作:转换,比较,算术运算,取整,取余,取最大值和最小值,取绝对值,取幂,取对数,取根号,取随机数,取符号,取精度,取舍入值等。 三、什么是包装类? 在实际开发过程中,...
void Hist_plane(BYTE *image_in, BYTE *image_out, int xsize, int ysize, long hist[256]); /*--------------------------特征提取-----------------------------*/ 20.区域标记 int Labeling(BYTE *image_in, ...
byte-Byte short-Short int -Integer long -Long float -Float double -Double char-Character boolean-Boolean 1、所属的包 java.lang 2、类的继承关系、实现接口 前面6个包装类是与数字相关的 父类:Number...
基本整数类型包括Shortint、Smallint、Longint、Int64、Byte、Word、Longword等,如下: 类型 范围 格式 Shortint -128..127 含符号的8位 Smallint -32768..32767 含符号的16位 Longint -2147483648...
原始类型封装类booleanBoolean charCharacter byteByte shortShort intInteger longLong floatFloat doubleDouble 引用类型和原始类型的行为完全不同,并且它们具有不同的语义。引用类型和原始类型具有不同的特征和...
void location(byte *image,int width,int height,int yuzhi,int *HL,int *HH,int *VL,int *VH); void huidu(struct Bmp1 img,byte *srcBmp,byte *dstBmp); void bmptwo(struct Bmp1 img,byte *srcBmp,byte *dstBmp,...
Int是java的原始数据类型,Integer是java为int提供的封装类。Java为每个原始类型提供了封装类。 原始类型 封装类 boolean Boolean char Character byte Byte short Short int Integer long Long float Float double ...