java字符串的各种编码转换
import java.io.UnsupportedEncodingException;
/**
* 转换字符串的编码
*/
public class ChangeCharset {
/** 7位ASCII字符,也叫作ISO646-US、Unicode字符集的基本拉丁块 */
public static final String US_ASCII = "US-ASCII";
/** ISO 拉丁字母表 No.1,也叫作 ISO-LATIN-1 */
public static final String ISO_8859_1 = "ISO-8859-1";
/** 8 位 UCS 转换格式 */
public static final String UTF_8 = "UTF-8";
/** 16 位 UCS 转换格式,Big Endian(最低地址存放高位字节)字节顺序 */
public static final String UTF_16BE = "UTF-16BE";
/** 16 位 UCS 转换格式,Little-endian(最高地址存放低位字节)字节顺序 */
public static final String UTF_16LE = "UTF-16LE";
/** 16 位 UCS 转换格式,字节顺序由可选的字节顺序标记来标识 */
public static final String UTF_16 = "UTF-16";
/** 中文超大字符集 */
public static final String GBK = "GBK";
/**
* 将字符编码转换成US-ASCII码
*/
public String toASCII(String str) throws UnsupportedEncodingException{
return this.changeCharset(str, US_ASCII);
}
/**
* 将字符编码转换成ISO-8859-1码
*/
public String toISO_8859_1(String str) throws UnsupportedEncodingException{
return this.changeCharset(str, ISO_8859_1);
}
/**
* 将字符编码转换成UTF-8码
*/
public String toUTF_8(String str) throws UnsupportedEncodingException{
return this.changeCharset(str, UTF_8);
}
/**
* 将字符编码转换成UTF-16BE码
*/
public String toUTF_16BE(String str) throws UnsupportedEncodingException{
return this.changeCharset(str, UTF_16BE);
}
/**
* 将字符编码转换成UTF-16LE码
*/
public String toUTF_16LE(String str) throws UnsupportedEncodingException{
return this.changeCharset(str, UTF_16LE);
}
/**
* 将字符编码转换成UTF-16码
*/
public String toUTF_16(String str) throws UnsupportedEncodingException{
return this.changeCharset(str, UTF_16);
}
/**
* 将字符编码转换成GBK码
*/
public String toGBK(String str) throws UnsupportedEncodingException{
return this.changeCharset(str, GBK);
}
相关文档:
java中的时间操作不外乎这四种情况:
1、获取当前时间
2、获取某个时间的某种格式
3、设置时间
4、时间的运算
好,下面就针对这四种情况,一个一个搞定。
一、获取当前时间
有两种方式可以获得,第一种,使用Date类。
j2SE的包里有两个Date类,一个是java.sql.Date,一个是java.util.Date
这里,要使用java.util. ......
程序执行时会顺序经过loading、linking、initialization三个步骤
1. loading:查找类或接口的二进制文件
2. linking:装入类或接口的二进制文件,合为JVM的运行状态,使其可以被执行。此过程包括三个子过程:verification, preparation, and
resolution of symbolic references
3. initialization: ......
简言之,如果不用第三方提供的接口
那最好的解决方案应该是当SESSION建立时sessionCreated(),在访问总数和当前在线人数上+1
当SESSION销毁时sessionDistroyed(),在线人数-1
核心方法是利用Listener监听的各种接口
我把代码(主要部分)贴在下面
此段代码我亲自使用过,没有问题
但因为继承了接口,有些未使用的方法也要� ......
document.body.oncopy = function() {
if (window.clipboardData) {
setTimeout(function() {
var text = clipboardData.getData("text&qu ......