Java Text File Save writeFile(String path, String contents)

Here you can find the source of writeFile(String path, String contents)

Description

write File

License

Open Source License

Declaration

public static void writeFile(String path, String contents)
            throws Exception 

Method Source Code

//package com.java2s;
/**//from ww w .  ja v a 2 s  .c o m
 * Copyright 2009, Google Inc.  All rights reserved.
 * Licensed to PSF under a Contributor Agreement.
 */

import java.io.BufferedWriter;

import java.io.FileWriter;

import java.io.PrintWriter;

public class Main {
    public static void writeFile(String path, String contents)
            throws Exception {
        PrintWriter out = null;
        try {
            out = new PrintWriter(new BufferedWriter(new FileWriter(path)));
            out.print(contents);
            out.flush();
        } finally {
            if (out != null) {
                out.close();
            }
        }
    }
}

Related

  1. writefile(String path, String content)
  2. writefile(String path, String content)
  3. writeFile(String path, String content)
  4. writeFile(String path, String content)
  5. writefile(String path, String content, boolean append)
  6. writeFile(String path, String data)
  7. writeFile(String path, String fileName, String content)
  8. writeFile(String path, String fileName, String content, String charset)
  9. writeFile(String path, String fileName, String data)