比如int转成byte数组,string转byte数组,string和基本类型之间的转换等等。
解决方案 »
- 为什么调用没有反映?先谢谢了
- java编程思想中的问题空间和问题空间元素,解空间怎么理解?
- JAVAGUI 一个问题 具体看贴
- java面试题(请老鸟帮忙一下)急啊!!!!!!!!!!!!!
- java 中一个线程被 Interrupt 后意味着什么? 多线程或异常处理的高手帮帮忙了,实在弄不清楚了
- jdbc中Statement.createStatement()的问题ResultSet.TYPE_SCROLL_INSENSITIVE和ResultSet.TYPE_SCORLL_SENSITIVE的区别
- 新手提问
- 在SWT中,如何设置Image对象的大小
- 往数据库中插入当前时间(年月日时分秒),怎么不能显示时分秒?
- javac 无法编译包含第三方jar包的项目
- 为什么eclipse里包内不能建包?
- 急 在线等.....................
string to byte
Byte static byte parseByte(String s)
byte to string
Byte static String toString(byte b)
char to string
Character static String to String (char c)
string to Short
Short static Short parseShort(String s)
Short to String
Short static String toString(Short s)
String to Integer
Integer static int parseInt(String s)
Integer to String
Integer static String tostring(int i)
String to Long
Long static long parseLong(String s)
Long to String
Long static String toString(Long i)
String to Float
Float static float parseFloat(String s)
Float to String
Float static String toString(float f)
String to Double
Double static double parseDouble(String s)
Double to String
Double static String toString(Double d)
2. 类的数据类型转换
//转换string为int
public static int stringToInt(String intstr)
{
Integer integer;
integer = Integer.valueOf(intstr);
return integer.intValue();
}
//转换int为string
public static String intToString(int value)
{
Integer integer = new Integer(value);
return integer.toString();
}
//转换string为float
public static float stringToFloat(String floatstr)
{
Float floatee;
floatee = Float.valueOf(floatstr);
return floatee.floatValue();
}
//转换float为string
public static String floatToString(float value)
{
Float floatee = new Float(value);
return floatee.toString();
}
//change the string type to the sqlDate type
public static java.sql.Date stringToDate(String dateStr)
{
return java.sql.Date.valueOf(dateStr);
}
//change the sqlDate type to the string type
public static String dateToString(java.sql.Date datee)
{
return datee.toString();
}
final static char[] digits = {
'0' , '1' , '2' , '3' , '4' , '5' ,
'6' , '7' , '8' , '9' , 'a' , 'b' ,
'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
'o' , 'p' , 'q' , 'r' , 's' , 't' ,
'u' , 'v' , 'w' , 'x' , 'y' , 'z'
};
private static String toUnsignedString(int i, int shift) {
char[] buf = new char[32];
int charPos = 32;
int radix = 1 << shift;
int mask = radix - 1;
do {
buf[--charPos] = digits[i & mask];
i >>>= shift;
} while (i != 0); return new String(buf, charPos, (32 - charPos));
}