public class Homework {
public static void main(String[] args)throws IOException{
try{
System.out.println("Please input your command:");
Scanner sc=new Scanner(System.in);
String command=sc.next();
String temp;
String[] text1=new String[5];
String[] text2=new String[5];
String information;
File fl=new File("D:\\StoreHouse.txt");
FileReader fr=new FileReader(fl);
BufferedReader br=new BufferedReader(fr);
StringBuffer SB=new StringBuffer(4096);
if(command.equals("show")){
while((temp=br.readLine())!=null){
SB.append(temp).append('\n');
System.out.println(SB);
}
br.close();
这是代码,在执行show命令时,D:\\StoreHouse.txt明明有中文,为什么显示的是一堆乱码,为什么,乱码如下:
Please input your command:
show
0001;�չ����;�������չ��;SR01;100
0001;�չ����;�������չ��;SR01;100
0002;�չ����;��ţ�չ��;QE01;10