分类：电脑/网络-程序设计-JAVA相关
问题：怎么让这个简单JAVA程序读写中文字符怎么让这个简单JAVA程序 
怎么让这个简单J程序读写并正确显示中文字符，现在它只能读写显示英文字符。//这是个简单的读写文本的程序import  .*;import  t.*;import javax.swing.*;import  t.event.*;public class Welcome extends JFrame implements ActionListener{   private JTextArea ioTextArea;   private JButton saveButton,openButton;   private JLabel 怎么让这个简单J程序读写并正确显示中文字符，现在它只能读写显示英文字符。//这是个简单的读写文本的程序import  .*;import  t.*;import javax.swing.*;import  t.event.*;public class Welcome extends JFrame implements ActionListener{   private JTextArea ioTextArea;   private JButton saveButton,openButton;   private JLabel label;   private FileInputStream inFile;   private FileOutputStream outFile;   private File file;   byte[] bufferArray=new byte[4096];  public Welcome(){     Container container=getContentPane();      tLayout(new FlowLayout());     label=new JLabel("文本显示及编辑区：");      tForeground( d);      d(label,BorderLayout.NORTH);     ioTextArea=new JTextArea("",10,20) ;      tEditable(true) ;      d(new JScrollPane(ioTextArea),BorderLayout.CENTER);     saveButton=new JButton("Save") ;      d(saveButton,BorderLayout.EAST);      dActionListener(this);     openButton=new JButton("Open") ;      d(openButton,BorderLayout.WEST);      dActionListener(this);     setSize(300,300);     setVisible(true);      }  public void actionPerformed(ActionEvent event){      if( tSource()==saveButton){       try{         outFile=new FileOutputStream(new File("test.txt"));         outFile.write( tText().getBytes(),0, tText().length());          ose();          owMessageDialog(this,"内容已保存到test.txt!");          }         catch(IOException e) {           owMessageDialog(this,"写入错误!","Error",JOptionPane.ERROR_MESSAGE);          System.exit(1);          }        }     else if( tSource()==openButton){       try{         file=new File("test.txt");         int fileLength=(int)file.length();         inFile=new FileInputStream(file);          ad(bufferArray,0,fileLength);         String str=new String();         for(int i=0;i<fileLength;i++){             str+=(char)bufferArray[i];            }          tText(str);          ose();          owMessageDialog(this,"文件已打开！");          }         catch(IOException e) {           owMessageDialog(this,"文件打开关闭时发生错误!","Error",JOptionPane.ERROR_MESSAGE);          System.exit(1);          }      }     }  public static void main(String args[]) {   Welcome welcome=new Welcome();    tDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        }}
回答：//改过的地方已经import  .*;import  t.*;import javax.swing.*;import  t.event.*;public class Welcome extends JFrame implements ActionListener{private JTextArea ioTextArea;private JButton saveButton,openButton;private JLabel label;private FileInputStream inFile;private FileOutputStream outFile;private DataOutputStream dos;//////////////////////////////private DataInputStream dis;///////////////////////////////private File file;byte[] bufferArray=new byte[4096];public Welcome(){Container container=getContentPane(); tLayout(new FlowLayout());label=new JLabel("文本显示及编辑区："); tForeground( d); d(label,BorderLayout.NORTH);ioTextArea=new JTextArea("",10,20) ; tEditable(true) ; d(new JScrollPane(ioTextArea),BorderLayout.CENTER);saveButton=new JButton("Save") ; d(saveButton,BorderLayout.EAST); dActionListener(this);openButton=new JButton("Open") ; d(openButton,BorderLayout.WEST); dActionListener(this);setSize(300,300);setVisible(true);}public void actionPerformed(ActionEvent event){if( tSource()==saveButton){try{outFile=new FileOutputStream(new File("test.txt"));dos = new DataOutputStream(outFile);///////////////////////////dos.writeUTF( tText());///////////////////////////// ose();////////////////////////////////////////////////// owMessageDialog(this,"内容已保存到test.txt!");} catch(IOException e) { owMessageDialog(this,"写入错误!","Error",JOptionPane.ERROR_MESSAGE);System.exit(1);}}else if( tSource()==openButton){try{file=new File("test.txt");int fileLength=(int)file.length();inFile=new FileInputStream(file);dis = new DataInputStream(inFile);///////////////////////String str=new String();str =  adUTF();//////////////////////////////////// tText(str); ose(); owMessageDialog(this,"文件已打开！");} catch(IOException e) { owMessageDialog(this,"文件打开关闭时发生错误!","Error",JOptionPane.ERROR_MESSAGE);System.exit(1);}}}public static void main(String args[]) {Welcome welcome=new Welcome(); tDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}}