Here you can find the source of makeTempDirectory(String prefix, String suffix)
Parameter | Description |
---|---|
prefix | the prefix to be used in generating the directory's name; must be at least three characters long |
suffix | the suffix to be used in generating the directory's name; may be <code>null</code>, in which case the suffix <code>.tmp</code> will be used |
Parameter | Description |
---|---|
IOException | if the directory could not be created |
public static File makeTempDirectory(String prefix, String suffix) throws IOException
//package com.java2s; /*//from w ww.java2s.com * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the JBPM BPEL PUBLIC LICENSE AGREEMENT as * published by JBoss Inc.; either version 1.0 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ import java.io.File; import java.io.IOException; public class Main { /** * Creates an empty directory in the default temporary-file directory, using the given prefix and * suffix to generate its name. * @param prefix the prefix to be used in generating the directory's name; must be at least three * characters long * @param suffix the suffix to be used in generating the directory's name; may be * <code>null</code>, in which case the suffix <code>.tmp</code> will be used * @return an abstract pathname denoting a newly-created empty directory * @throws IOException if the directory could not be created */ public static File makeTempDirectory(String prefix, String suffix) throws IOException { File dir = File.createTempFile(prefix, suffix); // delete temp file if (!dir.delete()) throw new IOException("could not delete temporary file: " + dir); // make temp directory if (!dir.mkdir()) throw new IOException("could not make temporary directory: " + dir); return dir; } }