当前位置: 技术问答>java相关
输入中文显示乱码是?????????为什么
来源: 互联网 发布时间:2015-06-28
本文导语: 我的程序:当输入中文时是一些问号,怎么回事? public static void main(String[] args) { byte buffer2[] = new byte[255]; String inputStr2=""; try { System.out.print ("请再输入一个字符串:") ; System.in.read(buffer2,0,255); inputStr2 = new ...
我的程序:当输入中文时是一些问号,怎么回事?
public static void main(String[] args)
{
byte buffer2[] = new byte[255];
String inputStr2="";
try
{
System.out.print ("请再输入一个字符串:") ;
System.in.read(buffer2,0,255);
inputStr2 = new String(buffer2,"Default");
System.out.println(buffer2);
inputStr2 =inputStr2.trim();
System.out.println ("你输入的字符串:"+inputStr2) ;
}
catch(Exception e){e.printStackTrace(); }
public static void main(String[] args)
{
byte buffer2[] = new byte[255];
String inputStr2="";
try
{
System.out.print ("请再输入一个字符串:") ;
System.in.read(buffer2,0,255);
inputStr2 = new String(buffer2,"Default");
System.out.println(buffer2);
inputStr2 =inputStr2.trim();
System.out.println ("你输入的字符串:"+inputStr2) ;
}
catch(Exception e){e.printStackTrace(); }
|
public static void main(String[] args)
{
byte buffer2[] = new byte[255];
String inputStr2="";
try
{
System.out.print ("请再输入一个字符串:") ;
System.in.read(buffer2,0,255);
inputStr2 = new String(buffer2,"GBK");
System.out.println(buffer2);
inputStr2 =inputStr2.trim();
System.out.println ("你输入的字符串:"+inputStr2) ;
}
catch(Exception e){e.printStackTrace(); }
}
{
byte buffer2[] = new byte[255];
String inputStr2="";
try
{
System.out.print ("请再输入一个字符串:") ;
System.in.read(buffer2,0,255);
inputStr2 = new String(buffer2,"GBK");
System.out.println(buffer2);
inputStr2 =inputStr2.trim();
System.out.println ("你输入的字符串:"+inputStr2) ;
}
catch(Exception e){e.printStackTrace(); }
}
|
把Default改成GBK或GB2312