Java FileOutputStream Write saveTempFile(String xmlSource, String fileName)

Here you can find the source of saveTempFile(String xmlSource, String fileName)

Description

save Temp File

License

Open Source License

Declaration

public static void saveTempFile(String xmlSource, String fileName) throws Throwable 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedOutputStream;
import java.io.File;

import java.io.FileOutputStream;

public class Main {
    public static String PATH = System.getProperty("user.dir");

    public static void saveTempFile(String xmlSource, String fileName) throws Throwable {

        if (fileName.isEmpty()) {
            fileName = "MissingId";
        }/*www . jav  a  2s. c  o  m*/

        File adhoc = new File(PATH + fileName + ".xml");

        if (adhoc.exists()) {
            adhoc.delete();
        }

        adhoc.createNewFile();

        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(adhoc));
        bos.write(xmlSource.getBytes());
        bos.close();
    }
}

Related

  1. saveStringIntoFile(File file, String contents)
  2. saveStringIntoFile(String filePath, String contents)
  3. saveStringsList(String file, Collection c)
  4. saveStringToFile(File file, String content, String charset)
  5. saveTemp(final byte[] data, final String suffix)
  6. saveTextContentInFile(String content, File file)
  7. saveTextToFile(String fileName, String content)
  8. saveTo(InputStream in, String fileName)
  9. saveTo(String path, InputStream in)