gpt4 book ai didi

java - 如何将 BigInteger 作为字节存储到文件中?

转载 作者:行者123 更新时间:2023-12-01 10:23:25 25 4
gpt4 key购买 nike

如何将 BigInteger Ca 的字节值存储到文本文件中?示例代码:

BigInteger Ca = new BigInteger("0");
Ca = OC.mod(N).multiply(R);
Ca = Ca.mod(N);

File file = new File("text.txt");
// create the file
file.createNewFile();
// create a FileWriter Object
FileWriter writer = new FileWriter(file);

最佳答案

    BigInteger Ca = new BigInteger("0");
byte[] array = Ca.toByteArray();
OutputStream fos = new FileOutputStream("text.txt");
ObjectOutputStream outputStream = new ObjectOutputStream(fos);
outputStream.write(array);
outputStream.close();
fos.close();

关于java - 如何将 BigInteger 作为字节存储到文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35456776/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com