易截截图软件、单文件、免安装、纯绿色、仅160KB

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中的类

      类是一个抽象的概念,是指把具有相同属性和相同行为特征的对象归为一体
      而对象就是一个具体的事物,它是属于某个类的一个特例     
      在一个类中,只有属性定义和方法定义部分,其他语句都是错误 ......

java中的对象赋值问题

在java中  可以将某个对象赋值给另一个对象  只要该两个对象是属于同一个类即可  此时  这两个对象的所有成员将指向同一块内存
eg:
      public class class1
         {
        &n ......

JAVA规范学习——实例创建时的操作

创建一个类的实例时,
1.会为它以及它的所有父类的实例变量分配内存空间,如果分配空间成功,则所有实例变量都会初始化为默认值0、false、null
2.会递归调用父构造函数,但是暂不执行构造函数的语句;
3.对该父构造函数对应的类的实例变量赋值
4.执行父构造函数的其他语句
5.对于子类,执行2-4步骤 ......

Java 多线程

1. 创建线程(继承Thread和实现runnable接口) class SubThread {
private class InnerThread extends Thread {
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
super.run();
}
}
public Thread getThread() {
return new InnerThread();
}
}
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号