java的文件操作问题

2025-05-23 20:17:06
推荐回答(1个)
回答1:

create a static method in a utility class to write the double to file.

public class IOUtil {
public static void writeToFile(double d, String filename) throws Exception {
// TODO: write double d to file
}
}

// to use it
double d = getRandomDouble();
String filename = "c:/tmp/myfile.txt";
IOUtil.writeToFile(d, filename);