Java Dump File dumpToFile(String name, String string)

Here you can find the source of dumpToFile(String name, String string)

Description

dump To File

License

Open Source License

Declaration

public static void dumpToFile(String name, String string) throws IOException 

Method Source Code

//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();
    }
}

Related

  1. dumpFile(final Reader rdr)
  2. dumpFile(String filename)
  3. dumpFile(String filename)
  4. dumpToFile(String dest, String content)
  5. dumpToFile(String fileName, String buffer, boolean append)
  6. dumptoTempFile(List lineItems)
  7. dumpToTemporaryFile(String modifiedSource, String modifiedPythonFile)