charsettest.java

来自「this is a java application」· Java 代码 · 共 30 行

JAVA
30
字号
import java.util.*;
import java.nio.charset.*;
class CharsetTest
{
	public static void main(String[] args) throws Exception
	{
		/*Map m=Charset.availableCharsets();
		Set names=m.keySet();
		Iterator it=names.iterator();
		while(it.hasNext())
		{
			System.out.println(it.next());
		}*/
		Properties pps=System.getProperties();
		//pps.list(System.out);
		pps.put("file.encoding","ISO-8859-1");
		int data;
		byte[] buf=new byte[100];
		int i=0;
		while((data=System.in.read())!='q')
		{
			buf[i]=(byte)data;
			i++;
		}
		String str=new String(buf,0,i);
		//System.out.println(str);
		String strGBK=new String(str.getBytes("ISO-8859-1"),"GBK");
		System.out.println(strGBK);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?