List of usage examples for java.io IOException getMessage
public String getMessage()
From source file:net.noday.core.dnspod.Dnspod.java
public static String domainInfo(String dnspodDomainId) { Document doc;/*from ww w. j a v a 2 s. com*/ try { doc = Jsoup.connect(url_domainInfo).data(data).data("domain_id", dnspodDomainId).userAgent(user_agent) .post(); JSONObject o = JSON.parseObject(doc.body().text()); String code = o.getJSONObject("status").getString("code"); if (StringUtils.equals(code, "1")) { return o.getJSONObject("domain").getString("ext_status"); } throw new DnspodException(o.getJSONObject("status").getString("message")); } catch (IOException e) { throw new DnspodException(e.getMessage()); } }
From source file:net.noday.core.dnspod.Dnspod.java
public static String domainCreate(Domain obj) { Document doc;/*from w w w .j a v a 2 s. c o m*/ try { doc = Jsoup.connect(url_domainCreate).data(data).data("domain", obj.getName()).userAgent(user_agent) .post(); JSONObject o = JSON.parseObject(doc.body().text()); String code = o.getJSONObject("status").getString("code"); if (StringUtils.equals(code, "1")) { return o.getJSONObject("domain").getString("id"); } throw new DnspodException(o.getJSONObject("status").getString("message")); } catch (IOException e) { throw new DnspodException(e.getMessage()); } }
From source file:wvw.utils.pc.HttpHelper.java
public static String post(String url, JSONArray headers, String data) { HttpPost httpPost = new HttpPost(url); for (int i = 0; i < headers.length(); i++) { JSONArray header = headers.getJSONArray(i); httpPost.addHeader(header.getString(0), header.getString(1)); }//from www .ja v a 2 s.co m String ret = null; try { httpPost.setEntity(new StringEntity(data)); HttpClient httpClient = new DefaultHttpClient(); HttpResponse response = httpClient.execute(httpPost); StatusLine status = response.getStatusLine(); switch (status.getStatusCode()) { case 200: ret = IOUtils.readFromStream(response.getEntity().getContent()); break; default: ret = genError(status.getReasonPhrase()); break; } } catch (IOException e) { // e.printStackTrace(); ret = genError(e.getClass() + ": " + e.getMessage()); } return ret; }
From source file:com.bah.applefox.main.plugins.pageranking.utilities.PRtoFile.java
private static HashMap<String, Double> createMap(String[] args) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { HashMap<String, Double> ret = new HashMap<String, Double>(); String readTable = args[13] + "Old"; Scanner scan = AccumuloUtils.connectRead(readTable); Iterator<Entry<Key, Value>> itr = scan.iterator(); while (itr.hasNext()) { Entry<Key, Value> temp = itr.next(); try {//from w w w. ja va 2 s . c o m Double val = (Double) IngestUtils.deserialize(temp.getValue().get()); ret.put(temp.getKey().getRow().toString(), val); System.out.println("Adding to Map: " + temp.getKey().getRow().toString() + " with rank: " + val); } catch (IOException e) { if (e.getMessage() != null) { log.error(e.getMessage()); } else { log.error(e.getStackTrace()); } } catch (ClassNotFoundException e) { if (e.getMessage() != null) { log.error(e.getMessage()); } else { log.error(e.getStackTrace()); } } } Double max = 0.0; Collection<Double> values = ret.values(); ArrayList<Double> tempValues = new ArrayList<Double>(); tempValues.addAll(values); Collections.sort(tempValues); Collections.reverse(tempValues); max = tempValues.get(0); ret.put("[[MAX_PR]]", max); return ret; }
From source file:de.egore911.versioning.deployer.performer.PerformReplacement.java
static void perform(File directory, List<String> wildcards, List<ReplacementPair> replacementsIn, List<File> replacementfiles) { List<ReplacementPair> replacements = new ArrayList<>(replacementsIn); for (File replacementfile : replacementfiles) { if (replacementfile.exists()) { Properties properties = new Properties(); try { properties.load(new FileInputStream(replacementfile)); } catch (IOException e) { LOG.error(e.getMessage(), e); return; }//from w ww.ja v a2 s . c om for (Entry<Object, Object> x : properties.entrySet()) { replacements .add(new ReplacementPair(((String) x.getKey()).trim(), ((String) x.getValue()).trim())); } } else { LOG.warn("Replacement file {} not found", replacementfile); } } perform(directory, wildcards, replacements); }
From source file:com.kennycason.kumo.LayeredWordCloudITest.java
private static Set<String> loadStopWords() { try {// w w w .java2s . c o m final List<String> lines = IOUtils.readLines(getInputStream("text/stop_words.txt")); return new HashSet<>(lines); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } return Collections.emptySet(); }
From source file:com.liferay.portal.struts.StrutsUtil.java
public static void forward(String uri, ServletContext ctx, HttpServletRequest req, HttpServletResponse res) throws ServletException { if (!res.isCommitted()) { String path = Constants.TEXT_HTML_DIR + uri; if (BrowserSniffer.is_wml(req)) { path = Constants.TEXT_WML_DIR + uri; }// www.ja v a2s . c o m ServletContext portalCtx = ctx.getContext(PropsUtil.get(PropsUtil.PORTAL_CTX)); if (portalCtx == null) { portalCtx = ctx; } RequestDispatcher rd = portalCtx.getRequestDispatcher(path); try { rd.forward(req, res); } catch (IOException ioe1) { Logger.error(StrutsUtil.class, ioe1.getMessage(), ioe1); } catch (ServletException se1) { req.setAttribute(PageContext.EXCEPTION, se1.getRootCause()); String errorPath = Constants.TEXT_HTML_DIR + Constants.COMMON_ERROR; if (BrowserSniffer.is_wml(req)) { path = Constants.TEXT_WML_DIR + Constants.COMMON_ERROR; } rd = portalCtx.getRequestDispatcher(errorPath); try { rd.forward(req, res); } catch (IOException ioe2) { Logger.error(StrutsUtil.class, ioe2.getMessage(), ioe2); } catch (ServletException se2) { throw se2; } } } else { _log.warn(uri + " is already committed"); } }
From source file:com.sm.store.cluster.Utils.java
public static String getLocalHost() { try {/*from ww w . j av a2s . c om*/ return Inet4Address.getLocalHost().getHostName(); } catch (IOException iex) { logger.error(iex.getMessage()); throw new RuntimeException(iex); } }
From source file:com.yattatech.util.SeminaryUtil.java
public static String copyImageFileToSeminaryFolder(String imagePath) { if (!IMAGE_COPY) { return imagePath; }/*from ww w . java2 s . com*/ if (isInImageFolder(imagePath)) { return imagePath; } final File file = new File(imagePath); if (file.exists()) { final String ext = FilenameUtils.getExtension(imagePath); final String path = getSeminaryImagePath() + java.util.UUID.randomUUID().toString() + '.' + ext; InputStream in = null; OutputStream out = null; try { in = new FileInputStream(imagePath); out = new FileOutputStream(path); IOUtils.copy(in, out); return path; } catch (IOException ioe) { LOGGER.log(Level.SEVERE, ioe.getMessage()); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } } return null; }
From source file:net.noday.core.dnspod.Dnspod.java
/** * /*from w ww . java2s . c om*/ * domain_id ??ID * sub_domain - , www * record_type APIA * record_line API * value - , IP:200.200.200.200, CNAME: cname.dnspod.com., MX: mail.dnspod.com. * mx {1-20} - MX, MX 1-20 * ttl {1-604800} - TTL1-604800??????? */ public static String recordCreate(DnsRecord obj) { Document doc; try { doc = Jsoup.connect(urlRecordCreate).data(data).data("domain_id", obj.getDnspodDomainId()) .data("sub_domain", obj.getSubDomain()).data("record_type", obj.getRecordTypeE().name()) .data("record_line", "").data("value", obj.getValue()).data("mx", "1") .data("ttl", obj.getTtl() + "").userAgent(user_agent).post(); JSONObject o = JSON.parseObject(doc.body().text()); String code = o.getJSONObject("status").getString("code"); if (StringUtils.equals(code, "1")) { return o.getJSONObject("record").getString("id"); } throw new DnspodException(o.getJSONObject("status").getString("message")); } catch (IOException e) { throw new DnspodException(e.getMessage()); } }