Here you can find the source of createTempDirectory(String prefix)
Parameter | Description |
---|---|
prefix | the prefix of the directory name. |
Parameter | Description |
---|---|
IOException | an exception |
static File createTempDirectory(String prefix) throws IOException
//package com.java2s; /**/* w w w . j a v a 2s. co m*/ * Copyright 2016 LinkedIn Corp. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ import java.io.File; import java.io.IOException; import java.nio.file.Files; public class Main { /** * Creates a temporary directory whose name starts with the given {@code prefix}. * @param prefix the prefix of the directory name. * @return the directory created as a {@link File} instance. * @throws IOException */ static File createTempDirectory(String prefix) throws IOException { File tempDir = Files.createTempDirectory(prefix).toFile(); tempDir.deleteOnExit(); return tempDir; } }