本帖最后由 remo866 于 2012-07-10 14:35:07 编辑

解决方案 »

  1.   


    try
            {   //如果try语句块里捕获到异常,就直接跳过try语句里最后一句的return line,所以就一直
    //停在System.out.println("str"+str);这里
                bufr = new BufferedReader(new InputStreamReader(System.in));
                bufw = new BufferedWriter(new OutputStreamWriter(System.out));
                //String line = null;             if((line=bufr.readLine())!=null)
                {
                    bufw.write(line,0,line.length());
                    bufw.newLine();
                    bufw.flush();
                }
                return line;        }
            catch (IOException e)   
            {
                throw new RuntimeException("读写失败");
            }
            finally
            {
                try
                {
                    if(bufr!=null)
                        bufr.close();
                    
                }
                catch (IOException e)
                {
                    throw new RuntimeException("读取流关闭失败");
                }
                try
                {
                    if(bufw!=null)
                        bufw.close();
                }
                catch (IOException e)
                {
                    throw new RuntimeException("写入流关闭失败");
                }
            }建议楼主在这里遇到异常就马上停止程序
      

  2.   

    没有遇到异常,我设置断点看了的。实际上我查看main方法里面变量变量都能看到值,但不会是sop语句错了吧。是什么原因呢?这个inputStr方法也能返回
      

  3.   

    把inputStr方法改成 public static String inputStr()
        {        
         Scanner input = new Scanner(System.in);
            String str = input.next();
            return str;
        }
      

  4.   

    如果说inputStr方法也能返回
    那你试试String str = "";  //将str = null, 改成str = ""试试
            System.out.println("请输入英文字符串");
            str = inputStr();//从键盘输入字符串
            System.out.println("str"+str);// 程序在这里结束了?调试也没找到原因
      

  5.   

    找到答案了 ,finally的代码关闭了in,out流导致。谢谢热心的朋友。