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);