Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Java SE 综合讨论区
» 实战错误讨论
打印话题 寄给朋友 订阅主题 |
作者 | 中文问题,困惑中 |
eqq2002
发贴: 22 积分: 0 |
于 2005-10-04 10:39
为何JFileChooser中文显示不出来啊,为何读文件中的中文读不出来啊,即使已经charset = "gb2312" private void openFile() { JFileChooser fileChooser = new JFileChooser(); //only file selected fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY ); int result = fileChooser.showOpenDialog( this ) ; if ( result == JFileChooser.CANCEL_OPTION ) { return; }//End of if User cancel selectedFile = fileChooser.getSelectedFile() ; if ( selectedFile == null || selectedFile.getName().equals("") ) { JOptionPane.showMessageDialog( this, "FileOpenError" , "File Error" , JOptionPane.ERROR_MESSAGE ); }//End of if SelectFile is null else { //open file try { outputTextArea.append( selectedFile.getName() + "\n" ); // InputStream kk = new FileInputStream( selectedFile ); BufferedReader fileInput = new BufferedReader(new FileReader(selectedFile)); //new BufferedReader( new InputStreamReader(kk,"GBK")); //new BufferedReader ( new FileReader( selectedFile) ) ; buffer = new StringBuffer() ; String text = ""; int lineIndex = 0 ; while ( ( text = fileInput.readLine() ) != null ) { buffer.append( text + "\n" ) ; outputTextArea.append( buffer.toString() ); if ( lineIndex != 0 ) { outputTextArea.append("DataArray " + lineIndex + " is below\n"); showResult( parseStringBySperator( text , SPERATOR ) ); }//End of inner IF for DataArray else { outputTextArea.append("FieldArray is below\n"); showResult( parseStringBySperator( text , SPERATOR ) ); }//End of else for FieldArray lineIndex ++ ; }//End of While }//End of Try to open File catch( IOException e) { JOptionPane.showMessageDialog( this, "IOError" , "File Error" , JOptionPane.ERROR_MESSAGE ); }//End of Catch Exception }//End of else try to set fileName and open inputStream }//End of Method openFile private String[] parseStringBySperator( String value , String sperator ) { String[] resultArray = value.split( sperator ); return resultArray; }//End of Method parseStringBySperator 有了Swing为什么还要SWT? |
话题树型展开 |
人气 | 标题 | 作者 | 字数 | 发贴时间 |
6887 | 中文问题,困惑中 | eqq2002 | 2632 | 2005-10-04 10:39 |
5910 | Re:中文问题,困惑中 | eqq2002 | 266 | 2005-10-11 23:37 |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |