是java写的,就是打开文件时,所有的中文都显示的是乱码。
private JMenuItem getOpen_jMenuItem() {
if (open_jMenuItem == null) {
open_jMenuItem = new JMenuItem("打开...");
open_jMenuItem.setAccelerator(KeyStroke.getKeyStroke('O',java.awt.Event.CTRL_MASK,true));
open_jMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
text_jTextArea1.setText("");
try {
JFileChooser openfile = new JFileChooser();
openfile.addChoosableFileFilter(openfile.getFileFilter());
if (openfile.APPROVE_OPTION != openfile.showOpenDialog(jContentPane)) {
return;
}
File file = openfile.getSelectedFile();
FileInputStream input = new FileInputStream(file);
int bytes;
while((bytes=input.read())>-1){
text_jTextArea1.append(String.valueOf((char)bytes));
}
input.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
}
return open_jMenuItem;
}
麻烦高手帮我解决一下,谢谢。