0
                if (bsave == e.getSource()) {
        path=null;
        try {
            getpath();
        } catch(Exception ee) {
            JOptionPane ss=new JOptionPane();
            ss.showMessageDialog(this,"Something wrong with the path....maybe Chinese name....");
        }
        if (path==null) return ;
        setTitle(path);
        try {
            File file=new File(path);   
            if(!file.exists()) file.createNewFile(); 
            FileWriter fw = new FileWriter(path,true);
            BufferedWriter bw = new BufferedWriter(fw);
            String myreadline=textf.getText();
            if (ty==0) {
                if (fw==null) System.out.println(fw);
                System.out.println(ty);
                bw.write(myreadline);
            } if (ty==1) {
                int len=myreadline.length();
                for (int i=0;i<len;i+=8) {
                    bw.write((char) chan.parseInt(myreadline.substring(i,i+7),2));
                }
            } else {
                int len=myreadline.length();
                for (int i=0;i<len;i+=2)
                    bw.write((char) chan.parseInt(myreadline.substring(i,i+1),16));
            }
            br.close();  
            fr.close();
        } catch(Exception e0) {
            System.out.println(e0.toString());
        }           
    }   

总的来说是这样的......但是因为它输出一个“0”,所以它必须在那里?

java.lang.NumberFormatException:对于输入字符串:“T”“

该字符串myreadline以“T”开头所以它尝试将其更改为数字......在写作时?我真的很困惑。。

4

1 回答 1

0

正如上面帖子中所评论的那样,FileWriter不会抛出NumberFormatException. 检查您的代码bw.write((char) chan.parseInt(myreadline.substring(i,i+7),2));。在这里,您将 String 解析为 Integer。

最简单的调试方法是将这些行包围在一个try-catch(RuntimeException){}块中,并仔细检查异常堆栈跟踪。

于 2013-09-08T17:21:21.703 回答