Here you can find the source of dumpToFile(String name, String string)
public static void dumpToFile(String name, String string) throws IOException
//package com.java2s; /*/*w w w . ja v a2 s .c om*/ * Copyright 2004 by EkoLiving Pty Ltd. All Rights Reserved. * * This software is the proprietary information of EkoLiving Pty Ltd. * Use is subject to license terms. */ import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { public static void dumpToFile(String name, String string) throws IOException { File file = new File(name); File parentFile = file.getParentFile(); if (parentFile.exists() == false) { if (parentFile.mkdirs() == false) throw new IOException("Unable to create directories for " + parentFile.getAbsoluteFile()); } FileWriter writer = new FileWriter(file); writer.write(string); writer.flush(); writer.close(); } }