List of usage examples for java.util UUID randomUUID
public static UUID randomUUID()
From source file:costumetrade.common.util.PdfUtils.java
public static File createImagePdfFile(String urlString) { File tempFile = new File(path + File.separator + UUID.randomUUID().toString() + ".pdf"); try (PDDocument doc = createImagePdf(urlString);) { doc.save(tempFile);// w w w .j a v a2 s . c o m } catch (IOException e) { throw new RuntimeException("?pdf", e); } return tempFile; }
From source file:Main.java
public static File saveBitmapToExternal(Bitmap bitmap, String targetFileDirPath) { if (bitmap == null || bitmap.isRecycled()) { return null; }/* ww w. j a va 2s. c om*/ File targetFileDir = new File(targetFileDirPath); if (!targetFileDir.exists() && !targetFileDir.mkdirs()) { return null; } File targetFile = new File(targetFileDir, UUID.randomUUID().toString()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); FileOutputStream fos = null; try { fos = new FileOutputStream(targetFile); baos.writeTo(fos); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } finally { try { baos.flush(); baos.close(); } catch (IOException e) { e.printStackTrace(); } try { if (fos != null) { fos.flush(); fos.close(); } } catch (IOException e) { e.printStackTrace(); } } return targetFile; }
From source file:org.createnet.raptor.db.AbstractStorage.java
static public String generateId() { return UUID.randomUUID().toString(); }
From source file:Main.java
public static String getGcmKey(final Context context, final String accountName) { SharedPreferences sp = getSharedPreferences(context); String gcmKey = sp.getString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_GCM_KEY), null); // if there is no current GCM key, generate a new random one if (TextUtils.isEmpty(gcmKey)) { gcmKey = UUID.randomUUID().toString(); Log.d("GoogleAcount", "No GCM key on account " + accountName + ". Generating random one: " + sanitizeGcmKey(gcmKey)); setGcmKey(context, accountName, gcmKey); }/*from w w w . j a v a 2 s . c o m*/ return gcmKey; }
From source file:org.mule.modules.cmis.automation.functional.TestDataBuilder.java
public static String generateRandomShortString() { return String.format("qaTest%s", new Object[] { UUID.randomUUID().toString().substring(0, 7) }); }
From source file:com.example.db.User.java
public static User createNew(final String username, final String password) { final String id = UUID.randomUUID().toString(); return new User(id, username, password, UserRole.forNormalUser(), LocalDateTime.now(ZoneId.of("UTC"))); }
From source file:com.fengduo.bee.commons.core.utils.Identities.java
/** * ?JDKUUID, Random?, -./*from ww w . j a va 2 s. c o m*/ */ public static String uuid2() { return UUID.randomUUID().toString().replaceAll("-", ""); }
From source file:codingsaint.util.UIDGenerator.java
/** * <code>getUID</code> :gives a JAVA UID * @return String :a universal Unique Identifier String *//*from w w w. j av a 2s .co m*/ public static String getUID() { return UUID.randomUUID().toString().toUpperCase(); }
From source file:com.pytsoft.cachelock.util.KeyUtils.java
/** * Generate lock value depends on expiration time to store in the target lock key. * * <p>The value is composed of a random UUID and expiration time separated by default namespace separator. * * @param lockExpire//from ww w .j a v a 2 s.c o m * Lock expiration time in milliseconds * * @return Lock value as string */ public static String genLockValue(long lockExpire) { long expireTime = System.currentTimeMillis() + lockExpire + 1; return UUID.randomUUID().toString() + Constants.NAMESPACE_SEPARATOR + expireTime; }
From source file:com.lakhi.employee.api.Session.java
public Session(String email) { this.email = email; this.accessToken = UUID.randomUUID().toString(); }