public static MaildirMessageName createUniqueName(MaildirFolder parentFolder,long size){
  String timestamp=String.valueOf(System.currentTimeMillis());
  timestamp=timestamp.substring(0,timestamp.length() - 3);
  StringBuilder uniquePart=new StringBuilder();
  uniquePart.append(Integer.toHexString(random.nextInt()));
  uniquePart.append(timestamp.substring(timestamp.length() - 3));
  uniquePart.append(processName);
  uniquePart.append(getNextDeliveryNumber());
  String sizeString=",S=" + String.valueOf(size);
  String fullName=timestamp + "." + uniquePart.toString()+ "."+ currentHostname+ sizeString;
  MaildirMessageName uniqueName=new MaildirMessageName(parentFolder,fullName);
  uniqueName.timestamp=timestamp;
  uniqueName.uniqueString=uniquePart.toString();
  uniqueName.hostname=currentHostname;
  uniqueName.sizeString=sizeString;
  uniqueName.isSplit=true;
  uniqueName.size=size;
  return uniqueName;
}

public static MaildirMessageName createUniqueName ( MaildirFolder parentFolder , long size ) { String timestamp = String . valueOf ( System . currentTimeMillis ( ) ) ; timestamp = timestamp . substring ( 0 , timestamp . length ( ) - 3 ) ; StringBuilder uniquePart = new StringBuilder ( ) ; uniquePart . append ( Integer . toHexString ( random . nextInt ( ) ) ) ; uniquePart . append ( timestamp . substring ( timestamp . length ( ) - 3 ) ) ; uniquePart . append ( processName ) ; uniquePart . append ( getNextDeliveryNumber ( ) ) ; String sizeString = ",S=" + String . valueOf ( size ) ; String fullName = timestamp + "." + uniquePart . toString ( ) + "." + currentHostname + sizeString ; MaildirMessageName uniqueName = new MaildirMessageName ( parentFolder , fullName ) ; uniqueName . timestamp = timestamp ; uniqueName . uniqueString = uniquePart . toString ( ) ; uniqueName . hostname = currentHostname ; uniqueName . sizeString = sizeString ; uniqueName . isSplit = true ; uniqueName . size = size ; return uniqueName ; }
create a name for a message according to < a href = " http : / / cr . yp . to / proto / maildir . html " / > < br / > the following elements are used : < br > < br / > " a unique name has three pieces , separated by dots . on the left is the result of time ( ) or the second counter from gettimeofday ( ) . on the right is the result of gethostname ( ) . ( to deal with invalid host names , replace / with \ 057 and : with \ 072 . ) in the middle is a delivery identifier , discussed below . < br / > < br / > modern delivery identifiers are created by concatenating enough of the following strings to guarantee uniqueness : < br / > < br / > [ . . . ] < br / > * rn , where n is ( in hexadecimal ) the output of the operating system ' s unix_cryptorandomnumber ( ) system call , or an equivalent source such as / dev / urandom . unfortunately , some operating systems don ' t include cryptographic random number generators . < br / > [ . . . ] < br / > * mn , where n is ( in decimal ) the microsecond counter from the same gettimeofday ( ) used for the left part of the unique name . < br / > * pn , where n is ( in decimal ) the process id . < br / > * qn , where n is ( in decimal ) the number of deliveries made by this process . < br / > < br / > [ . . . ] "
