List of usage examples for java.io UnsupportedEncodingException getMessage
public String getMessage()
From source file:io.cslinmiso.line.utils.Utility.java
/** * ??UTF-8//from w w w . j av a2s . c o m * * @param str * @return */ public static String unescapeString(String str) { String result = null; try { result = URLDecoder.decode(str, "UTF-8"); } catch (UnsupportedEncodingException e) { System.out.println("" + e.getMessage()); result = null; e.printStackTrace(); } return result; }
From source file:com.puppycrawl.tools.checkstyle.api.Utils.java
/** * Loads the contents of a file in a String array using * the named charset./*from w w w. j ava 2 s.c om*/ * @return the lines in the file * @param fileName the name of the file to load * @param charsetName the name of a supported charset * @throws IOException error occurred * @deprecated consider using {@link FileText} instead **/ @Deprecated public static String[] getLines(String fileName, String charsetName) throws IOException { final List<String> lines = Lists.newArrayList(); final FileInputStream fr = new FileInputStream(fileName); LineNumberReader lnr = null; try { lnr = new LineNumberReader(new InputStreamReader(fr, charsetName)); } catch (final UnsupportedEncodingException ex) { fr.close(); final String message = "unsupported charset: " + ex.getMessage(); throw new UnsupportedEncodingException(message); } try { while (true) { final String l = lnr.readLine(); if (l == null) { break; } lines.add(l); } } finally { Utils.closeQuietly(lnr); } return lines.toArray(new String[lines.size()]); }
From source file:cn.count.easydriver366.base.AppSettings.java
public static String getOutputParameters(List<NameValuePair> params) { StringBuilder result = new StringBuilder(); boolean first = true; try {//from www . ja v a 2 s . c om for (NameValuePair pair : params) { if (first) first = false; else result.append("&"); result.append(URLEncoder.encode(pair.getName(), "UTF-8")); result.append("="); result.append(URLEncoder.encode(pair.getValue(), "UTF-8")); } } catch (UnsupportedEncodingException e) { log(e.getMessage()); } return result.toString(); }
From source file:annis.libgui.Helper.java
/** * Parses the fragment.//from w w w .j a v a2 s. co m * * Fragments have the form key1=value&key2=test ... * @param fragment * @return */ public static Map<String, String> parseFragment(String fragment) { Map<String, String> result = new TreeMap<String, String>(); fragment = StringUtils.removeStart(fragment, "!"); String[] split = StringUtils.split(fragment, "&"); for (String s : split) { String[] parts = s.split("=", 2); String name = parts[0].trim(); String value = ""; if (parts.length == 2) { try { // every name that starts with "_" is base64 encoded if (name.startsWith("_")) { value = new String(Base64.decodeBase64(parts[1]), "UTF-8"); } else { value = URLDecoder.decode(parts[1], "UTF-8"); } } catch (UnsupportedEncodingException ex) { log.error(ex.getMessage(), ex); } } name = StringUtils.removeStart(name, "_"); result.put(name, value); } return result; }
From source file:com.googlecode.jsonrpc4j.JsonRpcHttpClient.java
private static String readString(InputStream stream) { if (stream == null) return "null"; try {//from www . j av a 2s. c o m StringBuilder buf = new StringBuilder(); BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); for (int ch = reader.read(); ch >= 0; ch = reader.read()) { buf.append((char) ch); } return buf.toString(); } catch (UnsupportedEncodingException e) { return e.getMessage(); } catch (IOException e) { return e.getMessage(); } finally { try { stream.close(); } catch (IOException e) { } } }
From source file:jongo.JongoUtils.java
/** * The length of the request body in octets (8-bit bytes) * @param input the string/*from w ww .jav a 2 s. co m*/ * @return an Integer with the length of the request body in octets. */ public static Integer getOctetLength(String input) { if (input == null) throw new IllegalArgumentException("Invalid null argument"); byte[] responseBytes; int result = 0; try { responseBytes = input.getBytes("UTF-8"); result = responseBytes.length; } catch (UnsupportedEncodingException ex) { l.error(ex.getMessage()); } return result; }
From source file:com.seer.datacruncher.eventtrigger.DynamicClassLoader.java
private static String extractClasspath(ClassLoader classLoader) { StringBuffer classLoaderBuf = new StringBuffer(); try {/*www .j a va 2s . c o m*/ while (classLoader != null) { if (classLoader instanceof URLClassLoader) { URL urls[] = ((URLClassLoader) classLoader).getURLs(); for (int i = 0; i < urls.length; i++) { if (classLoaderBuf.length() > 0) { classLoaderBuf.append(File.pathSeparatorChar); } classLoaderBuf.append(URLDecoder.decode(urls[i].getFile(), "UTF-8").toString()); } } classLoader = classLoader.getParent(); } } catch (UnsupportedEncodingException e) { logger.error("Exception:" + e.getMessage(), e); } return classLoaderBuf.toString(); }
From source file:com.ubb.imaging.ExifMetadataWriter.java
public static TiffOutputField getNewXPTitle(TiffOutputSet outputSet, String newTitle) { TiffOutputField tiffOutputField = null; try {//from w w w .j a v a2s .co m tiffOutputField = new TiffOutputField(TiffConstants.EXIF_TAG_XPTITLE, FieldType.BYTE, newTitle.getBytes("UTF-16").length, newTitle.getBytes("UTF-16")); } catch (UnsupportedEncodingException ex) { Logger.getLogger(ExifMetadataWriter.class.getName()).log(Level.SEVERE, ex.getMessage()); } return tiffOutputField; }
From source file:com.liferay.util.Http.java
public static String encodeURL(String url) { try {/*from w ww. j a v a 2 s . co m*/ return URLEncoder.encode(url, SystemProperties.get(FILE_ENCODING)); } catch (UnsupportedEncodingException uee) { Logger.error(Http.class, uee.getMessage(), uee); return StringPool.BLANK; } }
From source file:com.liferay.util.Http.java
public static String decodeURL(String url) { try {//from www . j av a2 s . c om return URLDecoder.decode(url, SystemProperties.get(FILE_ENCODING)); } catch (UnsupportedEncodingException uee) { Logger.error(Http.class, uee.getMessage(), uee); return StringPool.BLANK; } }