List of usage examples for java.lang String getBytes
public byte[] getBytes()
From source file:Main.java
/** * (java)write to file// w ww. j av a2s . c o m * * @param str * @param path */ public static void writeFile(String str, File file) { FileOutputStream out; try { file.createNewFile(); out = new FileOutputStream(file, false); String infoToWrite = str; out.write(infoToWrite.getBytes()); out.close(); } catch (IOException e) { Log.e("", "write error!"); } }
From source file:Main.java
public static InputStream String2InputStream(String str) { ByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); return stream; }
From source file:Main.java
public static InputStream stringToInputStream(String xml) { ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes()); return stream; }
From source file:ch.windmobile.server.social.mongodb.util.AuthenticationServiceUtil.java
public static boolean validateSHA1(String email, Object password, String base64) throws NoSuchAlgorithmException { if (password == null) { throw new IllegalArgumentException("password cannot be null"); }//from w w w. j a va 2s . co m MessageDigest md = MessageDigest.getInstance("SHA1"); String base = email + ":" + password.toString(); byte[] result = md.digest(base.getBytes()); byte[] data = Base64.decode(base64.getBytes()); return MessageDigest.isEqual(data, result); }
From source file:Main.java
public static boolean isDue(String str) { return isDue(str.getBytes()); }
From source file:Main.java
public static String str2Code(String str, String code) { try {//from w w w . ja v a 2 s.co m str = new String(str.getBytes(), code); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } return str; }
From source file:Main.java
public static boolean isAlphabetOrNumeric(String value) { try {/*from w w w . j a v a 2 s . com*/ byte[] b = value.getBytes(); for (int i = 0; i < b.length; i++) { if (ascnum(b[i]) == false) return false; } return true; } catch (Exception e) { return false; } }
From source file:Main.java
public static String encodeBase64String(String str) { try {/*from ww w . ja v a2 s.c o m*/ return new String(Base64.encode(str.getBytes(), Base64.DEFAULT)); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public final static String MD5(String s) { try {/*w ww. j a va2s .co m*/ byte[] btInput = s.getBytes(); MessageDigest mdInst = MessageDigest.getInstance("MD5"); mdInst.update(btInput); byte[] md = mdInst.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < md.length; i++) { int val = ((int) md[i]) & 0xff; if (val < 16) sb.append("0"); sb.append(Integer.toHexString(val)); } return sb.toString(); } catch (Exception e) { return null; } }
From source file:client.Client.java
static String toHex(String input) { return new String(Hex.encodeHex(input.getBytes())); }