java二进制,字节数组,字符,十六进制,BCD编码转换2007-06-07 00:17/** *//** * 把16进制字符串转换成字节数组 * @param hex * @return */ public static byte[] hexStringToByte(String hex) { int len = (hex.length() / 2); byte[] result = new byte[len]; char[] achar = hex.toCharArray(); for (int i = 0; i len; i++) { int pos = i * 2; result = (byte) (to...
by liuwanzhen - Java文档中心 - 2008-06-20 17:21:09 阅读(405) 回复(0)
/** * 把16进制字符串转换成字节数组 * @param hex * @return */ public static byte[] hexStringToByte(String hex) { int len = (hex.length() / 2); byte[] result = new byte[len]; char[] achar = hex.toCharArray(); for (int i = 0; i private static byte toByte(char c) { byte b = (byte) "0123456789ABCDEF".indexOf(c); return b; } /** * 把字节数组转换成16进制字符串...
二进制,字节数组,字符,十六进制,BCD编码转换 /** * 把16进制字符串转换成字节数组 * @param hex * @return */ public static byte[] hexStringToByte(String hex) { int len = (hex.length() / 2); byte[] result = new byte[len]; char[] achar = hex.toCharArray(); for (int i = 0; i private static byte toByte(char c) { byte b = (byte) "0123456789ABCDEF".indexOf(c); return b; } /** * 把...
来自:http://redhacker.blueidea.com/archives/2006/2890.shtml# 以下是一个简单的例子: Demo1: package test; import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.IOException; public class IOTest { /** * @param args * @throws IOException * @author dougq */ public static void main(String[] args) throws IOException { BufferedInputStream bs = new BufferedIn...
java基本类型 作者:臧圩人 基本类型,或者叫做内置类型,是java中不同于类的特殊类型。它们是我们编程中使用最频繁的类型,因此面试题中也总少不了它们的身影,在这篇文章中我们将从面试中常考的几个方面来回顾一下与基本类型相关的知识。 基本类型共有八种,它们分别都有相对应的包装类。关于它们的详细信息请看下表: 基本类型可以分为三类,字符类型char,布尔类型boolean以及数值类型byte、short、int、long、float、double。...
import java.text.*; import java.util.*; 1.----------------------------------------- 得到系统当前时间: java.util.Date dt=new java.util.Date(); System.out.print(dt); //输出结果是:Wed Aug 10 11:29:11 CST 2005 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); System.out.print(sdf.format(dt)); //输出结果是:2005-08-10 2.----------------------------------------- 把字符串转化为java.util.Date 方...
Normal 0 7.8 磅 0 2 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-...
Normal 0 7.8 磅 0 2 false false false MicrosoftInternetExplorer4 st1\:*{behavior:url(#ieooui) } /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; ...
new Date() will get the current time like: Calendar calendar = new GregorianCalendar(); return calendar.getTime(); if you want to set the hour and min to 0, you can calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); but this doesn't work(I don't know why) so I had to do like this: java.sql.Date.valueOf(DateUtils.formatDateToDate(new D...
java中数据转换 一,字符串转换成数字 (1)new Integer(字符串).inValue(); (2)int a=Integer.perseInt(字符串); 二,数字转换成字符串 int aa=10; Integer ab=new Integer(aa); String str=ab.toString(); 三,时间类型与时间字符串 (1)创建时间格式化字符串 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM- dd HH:mm:ss"); String timeStr=sdf.format(new Date()); (2)获得时间毫秒值...
一些初学java的朋友可能会遇到java的数据类型之间转换的苦恼,例如,整数和float,double型之间的转换,整数和String类型之间的转换,以及处理、显示时间方面的问题等。下面笔者就开发中的一些体会介绍给大家。 我们知道,java的数据类型分为三大类,即布尔型、字符型和数值型,而其中数值型又分为整型和浮点型;相对于数据类型,java的变量类型为布尔型boolean;字符型char;整型byte、short、int、long;浮点型float、double...