Here you can find the source of saveTempFile(String xmlSource, String fileName)
public static void saveTempFile(String xmlSource, String fileName) throws Throwable
//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(); } }