我正在尝试将 float 组列表存储到文件中。
我尝试使用 DataOutputStream 写入文件,它工作得很好,只是数据不是以人类可读的格式写入的。
我知道我必须使用打印编写器以文本格式写入数据,但它不支持写入浮点。
PrintWriter writer = new PrintWriter("filename.txt");
writer.write(naiveNearestPoints(points.get(i))); //Gives an error
writer.println(naiveNearestPoints(points.get(i)));//**updated** correct way to do it
是否有其他方法可以将浮点以可读格式写入文件?
最佳答案
PrintWriter
支持写入浮点值:print(float)
和 print(double)
.
关于java - 将 float 组写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42459774/