List of usage examples for java.lang String getBytes
public byte[] getBytes()
From source file:com.hangum.tadpole.commons.libs.core.utils.Base64Utils.java
/** * decode base64 util//from w w w .j a v a 2 s .co m * @param str * @return */ public static String base64Decode(String str) { byte[] decodedBytes = Base64.decodeBase64(str.getBytes()); return new String(decodedBytes); }
From source file:Main.java
public static String getStringDigestEncrypt(String s, String algorithm) { return getBytesDigestEncrypt(s.getBytes(), algorithm); }
From source file:org.runway.utils.TextUtils.java
/** * Generates Hash for the string passed/*from w w w. j a va 2s .c om*/ * @param original * @return */ public static String genHash(String original) { byte[] digested = original.getBytes(); byte[] encoded = Base64.encode(digested); return new String(encoded); }
From source file:org.alfresco.repo.events.JsonUtil.java
@SuppressWarnings("unchecked") public static Map<String, ?> readData(String data) { try {//from www . j a va2 s.c o m return mapper.readValue(data.getBytes(), Map.class); } catch (IOException error) { // do nothing return null; } }
From source file:Main.java
/** * encoded in utf-8, if exception, return defultReturn * * @param str/*www. j a v a2 s . co m*/ * @param defultReturn * @return */ public static String utf8Encode(String str, String defultReturn) { if (!isEmpty(str) && str.getBytes().length != str.length()) { try { return URLEncoder.encode(str, "UTF-8"); } catch (UnsupportedEncodingException e) { return defultReturn; } } return str; }
From source file:ZipDemo.java
public static final String uncompress(final String compressed) throws IOException { return ZipDemo.uncompress(compressed.getBytes()); }
From source file:Main.java
/** * Takes in the file stream to the offline file storage that is going to be written to and * the latest trip data that is going to be written to the offline storage file. * <p/>/*w w w . ja va2 s . c o m*/ * The new trip data will then be appended to the rest of the trip data. * * @param writer The output stream of the offline file for storage. Get this from {@link android.content.Context#openFileOutput} * @param line The new trip data as a String */ public synchronized static void writeToOfflineStorage(FileOutputStream writer, String line) { try { line += "\n"; writer.write(line.getBytes()); } catch (IOException e) { //TODO: Handle IO exception Log.d("ERROR", "IO Exception in OfflineUtilities#writeToOfflineStorage: " + e.getMessage()); } }
From source file:Main.java
public static String encodeBASE64(String s) { if (s == null) return null; return new String(Base64.encode(s.getBytes(), Base64.DEFAULT)); }
From source file:Main.java
public static String fillSpaceByByte(String str, int length) { byte[] strbyte = str.getBytes(); int strLength = strbyte.length; if (strLength >= length) { return str; }// w w w. j a va2 s. co m StringBuffer spaceBuffer = new StringBuffer(); for (int i = 0; i < (length - strLength); i++) { spaceBuffer.append(" "); } return str.concat(spaceBuffer.toString()); }
From source file:Main.java
/** * Build an XML Document from the data contained in the given String * @param data A String containing an XML document * @return A Document object equivalent to the XML document in the given String *//* w ww . java2 s . c o m*/ public static Document xml(String data) { return xml(new ByteArrayInputStream(data.getBytes())); }