1 22 package org.jboss.test.jmx.mbean; 23 24 import java.io.File ; 25 import java.io.FileWriter ; 26 import java.io.IOException ; 27 import java.net.URL ; 28 29 import org.jboss.logging.Logger; 30 import org.jboss.system.ServiceMBeanSupport; 31 32 34 40 public class TempFileCreatorService extends ServiceMBeanSupport 41 implements TempFileCreatorServiceMBean 42 { 43 private static Logger log = Logger.getLogger(TempFileCreatorService.class); 44 45 public TempFileCreatorService() 46 { 47 } 48 49 public URL createTempFile(String filename, String data) throws IOException 50 { 51 log.debug("Passed filename="+filename); 52 File file = File.createTempFile(filename,".xml"); 53 FileWriter fw = new FileWriter (file); 54 fw.write(data); 55 fw.close(); 56 file.deleteOnExit(); 57 URL url = file.toURL(); 58 log.debug("Temp file created="+url.toExternalForm()); 59 return url; 60 } 61 } 62 | Popular Tags |