java Unicode与中文互换
static String string2Unicode(String s) {
try {
StringBuffer out = new StringBuffer("");
byte[] bytes = s.getBytes("unicode");
for (int i = 2; i < bytes.length - 1; i += 2) {
out.append("u");
String str = Integer.toHexString(bytes[i + 1] & 0xff);
for (int j = str.length(); j < 2; j++) {
out.append("0");
}
String str1 = Integer.toHexString(bytes[i] & 0xff);
out.append(str);
out.append(str1);
out.append(" ");
}
return out.toString().toUpperCase();
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
}
static String unicode2String(String unicodeStr){
StringBuffer sb = new StringBuffer();
String str[] = unicodeStr.toUpperCase().split("U");
for(int i=0;i
相关文档:
public class JavaPlus {
public static void main(String[] args) {
int x = 5;
x++;// x = x + 1;//后加加
System.out.println(x);
x--;// x = x - 1;//后减减
System.out.println(x);
++x;// x = x + 1;//前加加
Sys ......
public class InsertBlobData {
Connection con = null;
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
InsertBlobData data = new InsertBlobData();
data.insertBlogInfo("002jpg", "sdsdfdf", "2007-02-1 ......
对枚举类型印象大多来自于C
语言,在
C
语言中,枚举类型是一个
HardCode
(硬编码)类型,其使用价值并不大。因此,在
Java 5
之前,枚举是被抛弃的。然而
Java 5
以后的发现版本开始对枚举进行支持,枚举的引入给
Java
世界带来了争议。
笔者比较赞同引入枚举,作为一门通用的静态编程语言,应该是 ......
public static String StringFilter(String str) throws
PatternSyntaxException {
// 只允许字母和数字
&nbs ......
java的Runtime.getRuntime().exec(commandStr)可以调用执行cmd指令。
cmd /c xx是执行完xx命令后关闭命令窗口。
cmd /k xx是执行完xx命令后不关闭命令窗口。
cmd /c start xx会打开一个新窗口后执行xx指令,原窗口会关闭。
cmd /k start xx会打开一个新窗口后执行xx指令,原窗口不会关闭。
可以用cmd /?查看帮助信息。 ......