List of usage examples for java.lang String getBytes
public byte[] getBytes()
From source file:Main.java
public static byte[] fullZore(String data, int blockSize) { byte[] dataBytes = data.getBytes(); int plaintextLength = dataBytes.length; if (plaintextLength % blockSize != 0) { plaintextLength = plaintextLength + (blockSize - (plaintextLength % blockSize)); }//from www . j ava 2 s . c om byte[] plaintext = new byte[plaintextLength]; System.arraycopy(dataBytes, 0, plaintext, 0, dataBytes.length); return plaintext; }
From source file:Main.java
private static byte[] hexStr2ByteArr(String strIn) throws Exception { byte[] arrB = strIn.getBytes(); int iLen = arrB.length; byte[] arrOut = new byte[iLen / 2]; for (int i = 0; i < iLen; i += 2) { String strTmp = new String(arrB, i, 2); arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16); }/* w ww . jav a 2 s . com*/ return arrOut; }
From source file:Main.java
public static void writeSCSocket(OutputStream os, String data) throws Exception { writeSCSocketBytes(os, data.getBytes(), data.length()); }
From source file:com.test.Base64Util.java
public static String encodeBase64(String message) { // /*w w w . j a va2 s . co m*/ byte[] result = Base64.encodeBase64(message.getBytes()); return new String(result); }
From source file:Main.java
public static String getMD5String(String s) { return getMD5String(s.getBytes()); }
From source file:Main.java
private static DatagramPacket getRequestPacket() { String request = "00002"; byte[] start_request_array = request.getBytes(); DatagramPacket request_packet = new DatagramPacket(start_request_array, start_request_array.length); return request_packet; }
From source file:Main.java
public static String encodeBase64(String s) { return Base64.encodeToString(s.getBytes(), Base64.DEFAULT); }
From source file:Main.java
/** * @comment_sp Agrega XMLNamespace/*from w w w. ja v a2 s . c o m*/ * @comment_ko addXMLNamespace * @param source * @param xmlNamespace * @return */ public static byte[] addXMLNamespace(byte source[], String xmlNamespace) { byte oldContent[] = new byte[source.length]; System.arraycopy(source, 0, oldContent, 0, source.length); String s = new String(oldContent); String inputNamespace = " xmlns=\"" + xmlNamespace + "\""; int start = s.indexOf("?>"); int fromIndex = s.indexOf("<", start); int toIndex = s.indexOf(">", fromIndex); StringBuffer sb = new StringBuffer(s); sb.insert(toIndex, inputNamespace); String input = new String(sb); return input.getBytes(); }
From source file:Main.java
public static InputStream stringToInputStream(String str) { InputStream is = new ByteArrayInputStream(str.getBytes()); return is;//from w ww .ja v a 2s . c o m }
From source file:Main.java
public static Bitmap convertBase64ToBitmap(String strBase64) { byte[] imageAsBytes = Base64.decode(strBase64.getBytes(), Base64.DEFAULT); Bitmap result = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length); return result; }