public static String decodeUTF8(String text) { try { return URLDecoder.decode(text, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new UnexpectedException(e); } }
public static String encodeUTF8(String text) { try { return URLEncoder.encode(text, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new UnexpectedException(e); } }
public static DOMImplementationRegistry getDomImplRegistry() { try { return DOMImplementationRegistry.newInstance(); } catch (ClassNotFoundException e) { throw new UnexpectedException(e); } catch (InstantiationException e) { throw new UnexpectedException(e); } catch (IllegalAccessException e) { throw new UnexpectedException(e); } }
public static URL newUrl(String url) { try { return new URL(url); } catch (MalformedURLException e) { throw new UnexpectedException(e); } }
public static DOMImplementationRegistry getDomImplRegistry() { try { return DOMImplementationRegistry.newInstance(); } catch (ClassNotFoundException e) { throw new UnexpectedException(e); } catch (InstantiationException e) { throw new UnexpectedException(e); } catch (IllegalAccessException e) { throw new UnexpectedException(e); } }
/** * Convert UTF-8 encoded byte arrays to a string * * @param utf8Chars UTF-8 characters byte array * @return Converted string. */ public static String utf8(byte[] utf8Chars) { try { return new String(utf8Chars, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new UnexpectedException(e); } }
public static DOMImplementationRegistry getDomImplRegistry() { try { return DOMImplementationRegistry.newInstance(); } catch (ClassNotFoundException e) { throw new UnexpectedException(e); } catch (InstantiationException e) { throw new UnexpectedException(e); } catch (IllegalAccessException e) { throw new UnexpectedException(e); } }
public static String encodeUTF8(String text) { try { return URLEncoder.encode(text, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new UnexpectedException(e); } }
public static URL newUrl(String url) { try { return new URL(url); } catch (MalformedURLException e) { throw new UnexpectedException(e); } }
public static void sleep(final long millis) { try { Thread.sleep(millis); } catch (InterruptedException e) { throw new UnexpectedException(e); } } }
public static String decodeUTF8(String text) { try { return URLDecoder.decode(text, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new UnexpectedException(e); } }
public static void sleep(final long millis) { try { Thread.sleep(millis); } catch (InterruptedException e) { throw new UnexpectedException(e); } } }
/** * Convert string to an UTF-8 encoded byte array * * @param str String to convert. * @return UTF-8 characters byte array */ public static byte[] utf8(String str) { try { return str.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new UnexpectedException(e); } }
private static CryptoEngine createEngine(String classname) { try { Class<?> cl = Class.forName(classname); return (CryptoEngine) cl.newInstance(); } catch (ClassNotFoundException e) { return null; } catch (InstantiationException e) { throw new UnexpectedException(e); } catch (IllegalAccessException e) { throw new UnexpectedException(e); } }
public static byte[] gzip(byte[] data) { try { ByteArrayOutputStream buf = new ByteArrayOutputStream(); GZIPOutputStream os = new GZIPOutputStream(buf); os.write(data); os.close(); return buf.toByteArray(); } catch (IOException e) { throw new UnexpectedException(e); } }
public static byte[] gzip(byte[] data) { try { ByteArrayOutputStream buf = new ByteArrayOutputStream(); GZIPOutputStream os = new GZIPOutputStream(buf); os.write(data); os.close(); return buf.toByteArray(); } catch (IOException e) { throw new UnexpectedException(e); } }
public static byte[] gzip(byte[] data) { try { ByteArrayOutputStream buf = new ByteArrayOutputStream(); GZIPOutputStream os = new GZIPOutputStream(buf); os.write(data); os.close(); return buf.toByteArray(); } catch (IOException e) { throw new UnexpectedException(e); } }
public static DocumentBuilder getDocumentBuilder(boolean namespaceAware) { try { return getDocumentBuilderFactory(namespaceAware).newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new UnexpectedException(e); } }
public static DocumentBuilder getDocumentBuilder(boolean namespaceAware) { try { return getDocumentBuilderFactory(namespaceAware).newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new UnexpectedException(e); } }
protected void readX509Key( String algorithm, byte[] encodedKey) throws InvalidKeyException { try { KeyFactory kf = KeyFactory.getInstance(algorithm); key = kf.generatePublic(new X509EncodedKeySpec(encodedKey)); } catch (NoSuchAlgorithmException e) { throw new UnexpectedException(e); } catch (InvalidKeySpecException e) { throw new InvalidKeyException(e); } } }