鉴于此方法:
public void OutputWrite (BigInteger[] EncryptCodes) throws FileNotFoundException{
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showSaveDialog(null);
String path = chooser.getSelectedFile().getAbsolutePath();
PrintWriter file = new PrintWriter(new File(path+"EncryptedMessage.txt"));
for (int i = 0; i <EncryptCodes.length; i++) {
file.write(EncryptCodes[i]+ " \r\n");
}
file.close();
}
Run Code Online (Sandbox Code Playgroud)
忽略变量名称,此方法的作用是写入EncryptCodes在项目文件夹中生成的txt文件中的数据EncryptedMessage.txt.
我需要的是一种方法来保存该txt文件而不是项目文件夹,以便在运行期间保存在用户指定的位置(打开另存为对话框).我认为它可以由JFilechooser完成,但我不能让它工作.
出于某种原因处理大数字时,模数运算符并没有给我正确的输出,看看代码
double x = Math.pow(65,17) % 3233;
Run Code Online (Sandbox Code Playgroud)
输出应该是2790
但输出是887.0
我确定它有点傻但我无法绕过它.提前致谢