List of usage examples for java.lang String getBytes
public byte[] getBytes()
From source file:Main.java
public static DatagramPacket getPacket(String msg) throws UnknownHostException { int PACKET_MAX_LENGTH = 1024; byte[] msgBuffer = msg.getBytes(); int length = msgBuffer.length; if (length > PACKET_MAX_LENGTH) { length = PACKET_MAX_LENGTH;/* www . j a v a 2s. c om*/ } DatagramPacket packet = new DatagramPacket(msgBuffer, length); InetAddress serverIPAddress = InetAddress.getByName("localhost"); packet.setAddress(serverIPAddress); packet.setPort(15900); return packet; }
From source file:att.jaxrs.util.Util.java
public static InputStream getInputStreamFromString(String string) { return new ByteArrayInputStream(string.getBytes()); }
From source file:com.jaspersoft.jasperserver.ps.OAuth.Utils.java
public static Map<String, String> getBasicAuthorizationHeader(String key, String secret) { Map<String, String> headers = new HashMap<String, String>(); String auth = key + ":" + secret; byte[] encodedAuth = Base64.encodeBase64(auth.getBytes()); String authHeader = "Basic " + new String(encodedAuth); headers.put("Authorization", authHeader); return headers; }
From source file:net.sf.jml.util.DigestUtils.java
public static String md5(String s) { byte[] result = md5(s.getBytes()); return NumberUtils.toHexValue(ByteBuffer.wrap(result)); }
From source file:Main.java
/** * Gets the bitmap image.//from w w w .j ava 2 s . c om * * @param context the context * @param base64 the base64 * @return the bitmap image */ public static Bitmap getBitmapImage(Context context, String base64) { String imagestring = base64; byte[] imageAsBytes = Base64.decode(imagestring.getBytes(), 5); return BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length); }
From source file:Main.java
public static String encryptHmacSHA384ToString(String data, String key) { return encryptHmacSHA384ToString(data.getBytes(), key.getBytes()); }
From source file:Main.java
public static String encryptHmacSHA256ToString(String data, String key) { return encryptHmacSHA256ToString(data.getBytes(), key.getBytes()); }
From source file:Main.java
public static String base64Encode(String s) { if (s == null) { return s; }// w w w.ja va 2 s. c om return Base64.encodeToString(s.getBytes(), Base64.NO_WRAP); }
From source file:Main.java
public static String encryptHmacSHA512ToString(String data, String key) { return encryptHmacSHA512ToString(data.getBytes(), key.getBytes()); }