java中bigdecimal的值为null,将bigdecimal写入文件时,会写入null,下面是代码,怎么样能写入空 。
public static void main(String[] args) {
String newStr = null;
BigDecimal bd = null;
//newStr = bd.toPlainString();
System.out.println(newStr);
newStr = String.format("%s", bd);
try {
BufferedWriter out = new BufferedWriter(new FileWriter("C:\\Users\\lishaoqing\\Desktop\\runoob.txt"));
out.write(newStr);
out.close();
System.out.println("文件创建成功!");
} catch (IOException e) {
}
}