Java AtomicLong getTempDirName()

Here you can find the source of getTempDirName()

Description

Return a string which can be used to create a directory in the temporary workspace of whatever is the meaning of the temp space in the present execution environment.

License

Apache License

Declaration

public static String getTempDirName() 

Method Source Code

//package com.java2s;
/**//from   w w  w  . j a  v  a2s  .co  m
 * Copyright (C) IBM Corp. 2009.
 * 
 * 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. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

import java.util.concurrent.atomic.AtomicLong;

public class Main {
    private static final AtomicLong uniqueId = new AtomicLong(System.currentTimeMillis());
    private static String tmpDirPath;

    /**
     * Return a string which can be used to create a directory in the
     * temporary workspace of whatever is the meaning of the temp space in the
     * present execution environment. Under linux it will return a file name 
     * under the /tmp directory, when run inside map-reduce it will return
     * a file in the temp working space of the task.
     * 
     * <br>
     * This call itself does not create the dir or ensure that the dir is deleted
     * on completion. It is the caller's responsibility to create the directory
     * and make sure that it is deleted on exit.
     * 
     * @return
     */
    public static String getTempDirName() {
        return tmpDirPath + uniqueId.incrementAndGet();
    }
}

Related

  1. getNextTestIndexName()
  2. getNowMicrosUtc()
  3. getRAMUniqueID()
  4. getRandomTopicName()
  5. getSequenceNumber()
  6. getTomorrowTime()
  7. getTrackedAllocationStatus()
  8. getUniqueURIString()
  9. greaterAndSet(long value, AtomicLong atomicValue)