num1=MyInput.readInt();
num2=MyInput.readDouble();
char1=MyInput.readChar();
string1=MyInput.readString();
你看看

解决方案 »

  1.   

    import java.io.*;
    public class myInput{
    public static double readDouble(){
    try
    {
    return Double.valueOf(readString().trim()).doubleValue();
    }
    catch (NumberFormatException ne)
    {
    System.err.println("Console.readDouble: Not adouble...");
    System.exit(-1);
    return 0.0;
    }
    }
    public static int readInt(){
    try
    {
    return Integer.valueOf(readString().trim()).intValue();
    }
    catch (NumberFormatException ne)
    {
    System.err.println("Console.readInt: Not an integer...");
    System.exit(-1);
    return -1;
    }
    }
    public static String readString(){
    BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    try
    {
    return in.readLine();
    }
    catch (IOException e)
    {
    System.out.println("Console.readString: Unknown error...");
    System.exit(-1);
    return "";
    }
    }
    public static char readChar(){
    return readString().charAt(0);
    }
    }
    调用就行了.
      

  2.   

    读字符串:
    public static void main(String[] args) throws IOException {
    LineNumberReader in = new LineNumberReader (new InputStreamReader(System.in));
    String param1 = in.readLine();
    in.close();相应的读其他int,double用相应的InputStream 或 Reader
      

  3.   

    用BufferdReader br=new BufferedReader(new InputStreamReader(System.in));流
    然后用一个tmp_str=br.readline();保存输入的字符串
    用循环把这字符串转化之后保存到你说的变量里
    最后用FileOutputStream fout 流输出到文件