List of usage examples for java.util UUID randomUUID
public static UUID randomUUID()
From source file:com.scf.utils.UUIDUtilies.java
public static String uuid() { UUID uuid = UUID.randomUUID(); return uuid.toString(); }
From source file:Main.java
public static String createUUID() { return UUID.randomUUID().toString().replace("-", ""); }
From source file:Main.java
public static String uploadFile(File file, String RequestURL) { String BOUNDARY = UUID.randomUUID().toString(); String PREFIX = "--", LINE_END = "\r\n"; String CONTENT_TYPE = "multipart/form-data"; try {// w w w . j ava 2 s .c om URL url = new URL(RequestURL); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(TIME_OUT); conn.setConnectTimeout(TIME_OUT); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty("Charset", CHARSET); conn.setRequestProperty("connection", "keep-alive"); conn.setRequestProperty("Content-Type", CONTENT_TYPE + ";boundary=" + BOUNDARY); if (file != null) { OutputStream outputSteam = conn.getOutputStream(); DataOutputStream dos = new DataOutputStream(outputSteam); StringBuffer sb = new StringBuffer(); sb.append(PREFIX); sb.append(BOUNDARY); sb.append(LINE_END); sb.append("Content-Disposition: form-data; name=\"img\"; filename=\"" + file.getName() + "\"" + LINE_END); sb.append("Content-Type: application/octet-stream; charset=" + CHARSET + LINE_END); sb.append(LINE_END); dos.write(sb.toString().getBytes()); InputStream is = new FileInputStream(file); byte[] bytes = new byte[1024]; int len = 0; while ((len = is.read(bytes)) != -1) { dos.write(bytes, 0, len); } is.close(); dos.write(LINE_END.getBytes()); byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINE_END).getBytes(); dos.write(end_data); dos.flush(); int res = conn.getResponseCode(); Log.e(TAG, "response code:" + res); if (res == 200) { return SUCCESS; } } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return FAILURE; }
From source file:Main.java
protected static String generateRandomBlobNameWithPrefix(String prefix) { if (prefix == null) { prefix = ""; }//from w w w . jav a 2s. co m String blobName = prefix + UUID.randomUUID().toString(); return blobName.replace("-", ""); }
From source file:co.runrightfast.core.utils.UUIDUtils.java
/** * * @return 32 char UUID */ static String uuid() { return StringUtils.remove(UUID.randomUUID().toString(), '-'); }
From source file:Main.java
/** * Returns a string with random characters. * * @return a string with random alpha-numeric characters.s */// ww w. java 2 s .co m public static String generateRandomString() { UUID uuid = UUID.randomUUID(); return String.valueOf(uuid); }
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(); setGcmKey(context, accountName, gcmKey); }/*www . j a va 2 s. co m*/ return gcmKey; }
From source file:com.scf.utils.UUIDUtilies.java
public static String base64Uuid() { UUID uuid = UUID.randomUUID(); return base64Uuid(uuid); }
From source file:Main.java
/** * <pre>/*from ww w .ja v a 2 s. co m*/ * Like {@link #putToCommonBundle(String, Object)} but does not require a key. The key is generated uniquely and returned. * </pre> */ public static String putToCommonBundle(Object value) { String key = UUID.randomUUID().toString(); sCommonBundle.put(key, value); return key; }
From source file:com.bootcamp.utils.IdGen.java
/** * ?JDKUUID, Random?, -./* ww w .ja va 2 s . c o m*/ */ public static String uuid() { return UUID.randomUUID().toString().replaceAll("-", ""); }