List of usage examples for org.apache.commons.codec.binary StringUtils newStringUtf8
public static String newStringUtf8(final byte[] bytes)
String
by decoding the specified array of bytes using the UTF-8 charset. From source file:at.supp.JsonTokenUtil2.java
public static String fromBase64ToJsonString(String source) { return StringUtils.newStringUtf8(Base64.decodeBase64(source)); }
From source file:com.ecama.utils.ImageEncoder.java
public List<String> encodeImage(List<Files> imageData) { List<String> imageList = new ArrayList<String>(); if (!imageData.isEmpty()) { for (Files file : imageData) { StringBuilder sb = new StringBuilder(); sb.append("data:image/jpg;base64,"); sb.append(StringUtils.newStringUtf8(Base64.encodeBase64(file.getFile(), false))); imageList.add(sb.toString()); }//w w w . j a va2 s .c o m } return imageList; }
From source file:com.smartitengineering.cms.api.impl.Utils.java
public static String readStringInUTF8(DataInput in) throws IOException, UnsupportedEncodingException { int allocationBlockSize = 2000; int capacity = allocationBlockSize; int length = 0; ByteBuffer buffer = ByteBuffer.allocate(allocationBlockSize); boolean notEof = true; while (notEof) { try {// ww w.j av a 2s . c om buffer.put(in.readByte()); if (++length >= capacity) { capacity += allocationBlockSize; buffer.limit(capacity); } } catch (EOFException ex) { notEof = false; } } String string = StringUtils.newStringUtf8(Arrays.copyOf(buffer.array(), length)); return string; }
From source file:lucene.security.accumulo.Base64.java
/** * Serialize to Base64 as a String, non-chunked. *///from ww w.ja v a 2 s .c o m public static String encodeBase64String(byte[] data) { /* * Based on implementation of this same name function in commons-codec 1.5+. * in commons-codec 1.4, the second param sets chunking to true. */ return StringUtils.newStringUtf8(org.apache.commons.codec.binary.Base64.encodeBase64(data, false)); }
From source file:com.itemanalysis.jmetrik.workspace.JmetrikPassword.java
public String encodePassword(String pw) { byte[] encodedBytes = Base64.encodeBase64(StringUtils.getBytesUtf8(pw)); String encodedContent = StringUtils.newStringUtf8(encodedBytes); return encodedContent; }
From source file:com.smartitengineering.cms.spi.impl.hbase.Utils.java
public static Date toDate(final byte[] dateBytes) { try {/* w ww .ja v a2 s.co m*/ String dateString = StringUtils.newStringUtf8(dateBytes); return DateUtils.parseDate(dateString, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() }); } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:com.ro.ssc.app.client.licensing.TrialKeyValidator.java
public static String decodeKey(String encodedEncrypted) { String decoded = ""; try {/*from w ww . j a v a 2 s . c o m*/ byte[] saltDecrypt = SALT_DECRYPT.getBytes(StandardCharsets.UTF_8); SecretKeyFactory factoryKeyDecrypt = SecretKeyFactory.getInstance(SECRET_KEY_FACTORY); SecretKey tmp2 = factoryKeyDecrypt.generateSecret( new PBEKeySpec(PASS_DECRYPT.toCharArray(), saltDecrypt, ITERATIONS_DECRYPT, KEY_LENGTH)); SecretKeySpec decryptKey = new SecretKeySpec(tmp2.getEncoded(), ALGORITHM); Cipher aesCipherDecrypt = Cipher.getInstance(CIPHER); aesCipherDecrypt.init(Cipher.DECRYPT_MODE, decryptKey); byte[] e64bytes = StringUtils.getBytesUtf8(encodedEncrypted); byte[] eBytes = Base64.decodeBase64(e64bytes); byte[] cipherDecode = aesCipherDecrypt.doFinal(eBytes); decoded = StringUtils.newStringUtf8(cipherDecode); } catch (Exception e) { LOGGER.error("Error while decoding the trial key", e); } return decoded; }
From source file:br.com.bob.dashboard.model.Job.java
@Override public String getJQueryName() { return StringUtils.newStringUtf8(title.getBytes()).replaceAll(" ", "_").toLowerCase(); }
From source file:com.itemanalysis.jmetrik.workspace.JmetrikPassword.java
public String decodePassword(String pw) { byte[] decode = Base64.decodeBase64(pw); String decodeString = StringUtils.newStringUtf8(decode); return decodeString; }
From source file:com.afrigis.services.addresssubmission.impl.AddressSubmissionResponseImpl.java
/** * * @param input/*from ww w. j a v a 2 s .co m*/ */ @Override protected void completeBuild(byte[] input) { if (isError()) { throw new AfriGISServicesException(getError()); } final String utf8Str = StringUtils.newStringUtf8(input); final Gson gson = new Gson(); data = gson.fromJson(utf8Str, AddressSubmissionResponsePojo.class); }