List of usage examples for java.lang String toString
public String toString()
From source file:de.inren.frontend.storehouse.picture.PictureResource.java
public static String getUrl(String digest) { String baseUrl = RequestCycle.get().getRequest().getContextPath(); String url = baseUrl.toString(); return url;//from ww w .j ava 2 s. co m // final ResourceReference imageResource = new UrlResourceReference( // PICTURE_RESOURCE); // return RequestCycle.get().urlFor(imageResource.getResource()) + "?" // + ID + "=" + digest; }
From source file:fr.ms.tomcat.manager.TomcatManagerUrl.java
public static String appelUrl(final String url, final String username, final String password, final String charset) throws MalformedURLException { LOG.debug("Parametre http get : " + url.toString()); final URL urlTomcat = new URL(url); return appelUrl(urlTomcat, username, password, charset); }
From source file:Main.java
public static void generateFile(String str) throws Exception { File target = new File(System.getProperty("user.dir") + "/src/sql1.txt"); FileOutputStream fos = new FileOutputStream(target); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, "utf-8")); bw.write(str.toString()); bw.close();/*from www .j a v a2 s . co m*/ }
From source file:eu.morfeoproject.fast.catalogue.util.Util.java
/** * @return the list of values associated with a header. Never null. */// w ww . java 2 s .com public static List<String> getHeader(HttpServletRequest request, String hname) { List<String> values = new ArrayList<String>(); Enumeration<?> hvals = request.getHeaders(hname.toString()); while (hvals.hasMoreElements()) { String hval = String.valueOf(hvals.nextElement()); values.add(hval); } return values; }
From source file:io.wcm.devops.conga.generator.util.VariableStringResolver.java
private static String resolve(String value, Map<String, Object> variables, int iterationCount) { if (iterationCount >= REPLACEMENT_MAX_ITERATIONS) { throw new IllegalArgumentException("Cyclic dependencies in variable string detected: " + value); }/*from www . j a v a 2s . c om*/ Matcher matcher = VARIABLE_PATTERN.matcher(value); StringBuffer sb = new StringBuffer(); boolean replacedAny = false; while (matcher.find()) { boolean escapedVariable = StringUtils.equals(matcher.group(1), "\\$"); String variable = matcher.group(2); if (escapedVariable) { // keep escaped variables intact matcher.appendReplacement(sb, Matcher.quoteReplacement("\\${" + variable + "}")); } else { Object valueObject = MapExpander.getDeep(variables, variable); if (valueObject != null) { String variableValue = valueToString(valueObject); matcher.appendReplacement(sb, Matcher.quoteReplacement(variableValue.toString())); replacedAny = true; } else { throw new IllegalArgumentException("Unknown variable: " + variable); } } } matcher.appendTail(sb); if (replacedAny) { // try again until all nested references are resolved return resolve(sb.toString(), variables, iterationCount + 1); } else { return sb.toString(); } }
From source file:org.shareok.data.plosdata.PlosUtil.java
/** * For some correspondences, there are no metadata about article title, <br> * instead, they is a title tag//from w ww .ja va 2 s . c om * @param html : The string of the web page source * @return title */ public static String getTitleFromHtml(String html) { String title = ""; Document doc = Jsoup.parse(html.toString()); Elements titleElements = doc.select("title"); if (null != titleElements && titleElements.size() > 0) { title = titleElements.get(0).text(); } return title; }
From source file:com.worldline.easycukes.commons.helpers.FileHelper.java
/** * Downloads some content from an URL to a specific directory * * @param from a {@link String} representation of the URL on which the * content should be downloaded * @param to the path on which the content should be downloaded * @throws IOException if anything's going wrong while downloading the content to * the specified directory *//*w w w. j a va 2 s . co m*/ public static void download(@NonNull String from, @NonNull String to) throws IOException { final URL url = new URL(from); log.debug("Downloading from: " + url.toString() + " to: " + to.toString()); final String zipFilePath = to + url.getFile().substring(url.getFile().lastIndexOf('/')); FileUtils.copyURLToFile(url, new File(zipFilePath), 30000, 300000); }
From source file:Main.java
public static File save2File(String savePath, String saveName, String crashReport) { try {//from w w w. ja va2s. c o m File dir = new File(savePath); if (!dir.exists()) dir.mkdir(); File file = new File(dir, saveName); FileOutputStream fos = new FileOutputStream(file); fos.write(crashReport.toString().getBytes()); fos.close(); return file; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:org.shareok.data.plosdata.PlosUtil.java
public static String getPlosAck(String html) { String ack = ""; Document doc = Jsoup.parse(html.toString()); Elements ackLinks = doc.select("a[id=ack]"); if (!ackLinks.isEmpty()) { Element ackDiv = ackLinks.first().parent(); if (null != ackDiv) { Elements ackParagraphs = ackDiv.select("p"); if (!ackParagraphs.isEmpty()) { for (Element element : ackParagraphs) { if (element.hasText()) ack += element.text(); }/* w w w .j ava 2 s. com*/ } //System.out.println("the ack = "+ack+"\n\n"); } } return ack; }
From source file:Main.java
public static Document newXmlDocument(String xml) { try {/*from w w w. j a v a 2 s . c o m*/ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); return docBuilder.parse(new InputSource(new StringReader(xml.toString()))); } catch (ParserConfigurationException | SAXException | IOException ex) { System.err.println("Error: Canot create new XML document"); System.err.println("Cause: " + ex.getMessage()); System.exit(1); return null; } }