Java AtomicInteger getTempFileName()

Here you can find the source of getTempFileName()

Description

Method (3)

License

Open Source License

Declaration

public static String getTempFileName() 

Method Source Code

//package com.java2s;

import java.util.concurrent.atomic.AtomicInteger;

public class Main {
    public static final String chars = "0123456789abcdefghijklmnopqrstuvwxyz-_$!~";
    public static final long base = chars.length();
    private static final AtomicInteger ai = new AtomicInteger(0);
    static CharSequence seqStart;

    /**//from  w  w w  . j a  v  a  2s .  c  o m
     * Method (3)
     */
    public static String getTempFileName() {
        StringBuilder res = new StringBuilder(12);
        res.append(seqStart);
        res.append(fromDecimal(ai.getAndIncrement()));
        return res.toString();
    }

    private static CharSequence fromDecimal(long number) {
        StringBuilder result = new StringBuilder(12);
        do {
            result.insert(0, chars.charAt((int) (number % base)));
            number /= base;
        } while (number > 0);

        return result;

    }
}

Related

  1. getQueryCounters()
  2. getRandom()
  3. getRandomTenantId()
  4. getReply()
  5. getSerialNum()
  6. getThreadDumpId()
  7. getThreadName(String pattern, String name)
  8. getTimeBasedUUID()
  9. getUniqueId()