import java.io.*;public class KeyInStr {        public static void main(String[] args) {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String s;
            System.out.print("Input a string");
            System.out.flush();
            s = br.readLine(); //;;;;;;;;
            double d = Double.parseDouble(s);
            System.out.println( +2.0 * d);
          }catch(Exception e){}
        }
}

解决方案 »

  1.   

    s = br.readLine();
    --------------------------
    这句必须抛出java.io.IOExceptiontry {
       s = br.readLine();                
    } catch (java.io.IOException e) {
       
    }
      

  2.   


    因为有异常,所以要么Throws,要么Catch
    public static void main(String[] args) throws IOException {第二,看J2SD的api文件
      

  3.   

    Java有API Document,在java.sun.com可以找到下载链接
    代码有错是因为没有捕捉IOException异常,br.readLine()可能产生IOException异常
      

  4.   

    import java.io.*;public class KeyInStr { public static void main(String[] args) {
    //不要忘了加入异常判断
    try{
            BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in));
            String s;
            System.out.print("Input a string");
            System.out.flush();     
            s = br.readLine();                
            double d = Double.parseDouble(s);
            System.out.println(+2.0*d);
    }
    catch(IOException e)
    {}
    }
    }
      

  5.   

    import java.io.*;public class KeyInStr { public static void main(String[] args) {

    try
    { BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in));
    String s;
    System.out.print("Input a string");
    System.out.flush();     
    s = br.readLine();                //<-----编 译 器 提 示 这 行 错 ,为 啥  ?
    double d = Double.parseDouble(s);
    System.out.println(+2.0*d);
    }
    catch (Exception e)
    {
    System.out.println (e.toString ());
    }

    }
    }
    加个错误处理就可以了,帮助可以到网上下载,API DOC!!
      

  6.   

    第二个问题,晚上找得到chm格式的API文档,google哈
      

  7.   

    1、  为 什 么 下 面 这 个 程 序 编 译 不 过 呢没有报告异常,java.io.IOException 必须捕获或抛出解决方案
    a、将 异常捕获
    将 s = br.readLine();try {
        s = br.readLine();
    }catch (IOException e) {
        System.out.println(e.getMessage());
    }b、将异常抛出
    将 public static void main(String[] args){
    换成 public static void main(String[] args) throws IOException {外你要注意将 s初始化,例如写成 s = null; 或 s = "",否则还是会报错2. 请 问 Java 有 没 有 类 似  MSDN那 样 的 帮 助 文 档 , 也 就 是 可 以 查 到 相 关 的 函 数 , 类 说 明 , 参 数 说 明 , 范 例 等 。请参考
    http://java.sun.com/j2se/1.4.2/docs/api/index.html
      

  8.   

    凡是涉及到 I/O、 网络、数据库的这方面的代码时,一般都是要加上try catch的,不然编译器就会报错的!