All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jmatrix.db.common.StringUtils Maven / Gradle / Ivy

The newest version!
package net.jmatrix.db.common;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import sun.misc.BASE64Encoder;

/**
 * 
 */
public class StringUtils {
   static Map padmapper=new HashMap();
   
   static BASE64Encoder b64=new BASE64Encoder();
   
   public static final String pad(int w, char c) {
      String s=padmapper.get(w+"-"+c);
      
      if (s != null)
         return s;
      StringBuilder sb=new StringBuilder();
      for (int i=0; i>> 56),
           (byte)(longOne >>> 48),
           (byte)(longOne >>> 40),
           (byte)(longOne >>> 32),   
           (byte)(longOne >>> 24),
           (byte)(longOne >>> 16),
           (byte)(longOne >>> 8),
           (byte) longOne,
           (byte)(longTwo >>> 56),
           (byte)(longTwo >>> 48),
           (byte)(longTwo >>> 40),
           (byte)(longTwo >>> 32),   
           (byte)(longTwo >>> 24),
           (byte)(longTwo >>> 16),
           (byte)(longTwo >>> 8),
           (byte) longTwo
            };
      
      String s=b64.encode(b).replaceAll("=", "");
      
      System.out.println ("    '"+uuid+"'");
      System.out.println ("    '"+s+"'");
      
      return s;
   }
   
   public static void main(String args[]) {
      shortUUID();
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy