如何从命令提示符读取数据并写入文件?

时间:2013-05-23 07:49:49

标签: java command-prompt

public void fitModel(String opFileName) {
    double alpha = 0.477;
    double[][] data = new double[time.length][order];
    for (int row = 0; row < time.length; row++) {
        for (int col = 0; col < order; col++) {
            data[row][col] = Math.tanh(alpha * (col + 1) * time[row]);
        }
    }
    computeCoeff(data);
    doPrediction(data, opFileName, true);

    }

    System.out.println();
    System.out.println("Model Parameters :");
    for (int i = 0; i < coeff.length; i++) {
        System.out.println(coeff[i]);
    }

    System.out.println();
    System.out.println("% deviation : " + deviation
            / (prediction.length - zeroRecCnt));
}

}

命令提示符显示三个颜色输入,输出,预测。 我需要读取这三个coloumns,并将数据写入文本文件。 你能帮帮我吧。

1 个答案:

答案 0 :(得分:0)

扫描仪可能是个不错的选择:

Scanner scanner = new Scanner(new InputStreamReader(System.in));
System.out.println("Reading input from console using Scanner in Java ");
System.out.println("Please enter your input: ");
String input = scanner.nextLine();
System.out.println("User Input from console: " + input);
System.out.println("Reading int from console in Java: ");
int number = scanner.nextInt();
System.out.println("Integer input: " + number);