List of usage examples for java.lang String concat
public String concat(String str)
From source file:PropertyLoader.java
public static Properties loadProperties(String name, ClassLoader loader) throws Exception { if (name.startsWith("/")) name = name.substring(1);//from ww w . java 2s . co m if (name.endsWith(SUFFIX)) name = name.substring(0, name.length() - SUFFIX.length()); Properties result = new Properties(); InputStream in = null; if (loader == null) loader = ClassLoader.getSystemClassLoader(); if (LOAD_AS_RESOURCE_BUNDLE) { name = name.replace('/', '.'); ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault(), loader); for (Enumeration keys = rb.getKeys(); keys.hasMoreElements();) { result.put((String) keys.nextElement(), rb.getString((String) keys.nextElement())); } } else { name = name.replace('.', '/'); if (!name.endsWith(SUFFIX)) name = name.concat(SUFFIX); in = loader.getResourceAsStream(name); if (in != null) { result = new Properties(); result.load(in); // can throw IOException } } in.close(); return result; }
From source file:jmc.util.UtlFbComents.java
public static String getJSONComentarios(String url, Long numComents) throws JMCException { String linea = ""; String buf = ""; try {// w ww .j a va 2 s. c om Properties props = ConfigPropiedades.getProperties("props_config.properties"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); URL ur = new URL( "http://graph.facebook.com/comments?id=" + url + "&limit=" + numComents + "&filter=stream"); HttpURLConnection cn = (HttpURLConnection) ur.openConnection(); cn.setRequestProperty("user-agent", props.getProperty("navegador")); cn.setInstanceFollowRedirects(false); cn.setUseCaches(false); cn.connect(); BufferedReader br = new BufferedReader(new InputStreamReader(cn.getInputStream())); while ((linea = br.readLine()) != null) { buf.concat(linea); } cn.disconnect(); } catch (IOException e) { throw new JMCException(e); } return buf; }
From source file:org.openpplsoft.sql.StmtLibrary.java
/** * Generates the SELECT clause given a record defn. * @param recDefn the record definition to select from * @param tableAlias the alias for the record (if none, use empty str) * @return the SELECT clause in string form *///from www. j a v a 2 s .c om private static String generateSelectClause(final Record recDefn, final String tableAlias, final boolean delimitFieldsWithSpace) { String dottedAlias = tableAlias; if (dottedAlias.length() > 0) { dottedAlias = dottedAlias.concat("."); } final StringBuilder selectClause = new StringBuilder("SELECT "); final String[] aliasedFields = getOptionallyAliasedFieldsToSelect(recDefn, dottedAlias, false); for (int i = 0; i < aliasedFields.length; i++) { if (i > 0) { selectClause.append(','); if (delimitFieldsWithSpace) { selectClause.append(' '); } } selectClause.append(aliasedFields[i]); } selectClause.append(" FROM ").append(recDefn.getDbTableName()).append(' ').append(tableAlias); return selectClause.toString(); }
From source file:com.fiveamsolutions.nci.commons.search.SearchableUtils.java
/** * @param selectClause/*from w ww . ja v a 2 s . c o m*/ * @param attributes * @param isCountOnly * @return */ private static void constructDistinctClause(StringBuffer selectClause, List<String> attributes, boolean isCountOnly) { String distinctClause; if (attributes == null || attributes.isEmpty()) { distinctClause = DISTINCT.concat(ROOT_OBJ_ALIAS); } else { distinctClause = DISTINCT; for (Iterator<String> iterator = attributes.iterator(); iterator.hasNext();) { String attr = (String) iterator.next(); distinctClause = distinctClause.concat(ROOT_OBJ_ALIAS + DOT + attr); if (iterator.hasNext()) { distinctClause = distinctClause.concat(COMMA); } } } selectClause.append(isCountOnly ? "COUNT (" + distinctClause + ")" : distinctClause); }
From source file:es.bsc.servicess.ide.editors.deployers.ImageCreation.java
private static String generateTemplate(Map<String, String> maxConstraints) { String imageTemplate = new String("<ImageTemplate>"); String OS = maxConstraints.get(ConstraintsUtils.OS.getName()); if (OS != null && !OS.contains(",")) { imageTemplate = imageTemplate.concat("<operatingSystem>" + OS + "</operatingSystem>"); } else// w ww . j a v a 2 s.com imageTemplate = imageTemplate.concat("<operatingSystem>Linux</operatingSystem>"); String arch = maxConstraints.get(ConstraintsUtils.PROC_ARCH.getName()); if (arch != null && !arch.contains(",")) { imageTemplate = imageTemplate.concat("<architecture>" + arch + "</architecture>"); } String imageSize = maxConstraints.get(ConstraintsUtils.STORAGE_SIZE.getName()); if (imageSize != null) { int f = (int) Float.parseFloat(imageSize) / 1; //f= f/1024; imageTemplate = imageTemplate.concat("<imageSize>" + f + "</imageSize>"); } else { int f = (int) IDEProperties.DEFAULT_DISK / 1024; imageTemplate = imageTemplate.concat("<imageSize>" + f + "</imageSize>"); } imageTemplate = imageTemplate.concat("</ImageTemplate>"); return imageTemplate; }
From source file:net.java.sip.communicator.impl.certificate.CertificateServiceImpl.java
/** * Appends an index number to the alias of each entry in the KeyStore. * /*from w ww.j a v a2s . c om*/ * The Windows TrustStore might contain multiple entries with the same * "Friendly Name", which is directly used as the "Alias" for the KeyStore. * As all operations of the KeyStore operate with these non-unique names, * PKIX path building could fail and in the end lead to certificate warnings * for perfectly valid certificates. * * @throws Exception when the aliases could not be renamed. */ private static int keyStoreAppendIndex(KeyStore ks) throws Exception { Field keyStoreSpiField = ks.getClass().getDeclaredField("keyStoreSpi"); keyStoreSpiField.setAccessible(true); KeyStoreSpi keyStoreSpi = (KeyStoreSpi) keyStoreSpiField.get(ks); if ("sun.security.mscapi.KeyStore$ROOT".equals(keyStoreSpi.getClass().getName())) { Field entriesField = keyStoreSpi.getClass().getEnclosingClass().getDeclaredField("entries"); entriesField.setAccessible(true); Collection<?> entries = (Collection<?>) entriesField.get(keyStoreSpi); int i = 0; for (Object entry : entries) { Field aliasField = entry.getClass().getDeclaredField("alias"); aliasField.setAccessible(true); String alias = (String) aliasField.get(entry); aliasField.set(entry, alias.concat("_").concat(Integer.toString(i++))); } return i; } return -1; }
From source file:com.hpe.application.automation.tools.srf.run.RunFromSrfBuilder.java
public static JSONObject getSrfConnectionData(AbstractBuild<?, ?> build, PrintStream logger) { try {/* ww w. j a v a 2s. com*/ CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); // Create all-trusting host name verifier HostnameVerifier allHostsValid = new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }; HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); String path = build.getProject().getParent().getRootDir().toString(); path = path.concat("/com.hpe.application.automation.tools.settings.SrfServerSettingsBuilder.xml"); File file = new File(path); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.parse(file); // This also shows how you can consult the global configuration of the builder JSONObject connectionData = new JSONObject(); String app = document.getElementsByTagName("srfAppName").item(0).getTextContent(); String tenant = app.substring(1, app.indexOf('_')); String secret = document.getElementsByTagName("srfSecretName").item(0).getTextContent(); String server = document.getElementsByTagName("srfServerName").item(0).getTextContent(); boolean https = true; if (!server.startsWith("https://")) { if (!server.startsWith("http://")) { String tmp = server; server = "https://"; server = server.concat(tmp); } else https = false; } URL urlTmp = new URL(server); if (urlTmp.getPort() == -1) { if (https) server = server.concat(":443"); else server = server.concat(":80"); } String srfProxy = ""; String srfTunnel = ""; try { srfProxy = document.getElementsByTagName("srfProxyName").item(0).getTextContent().trim(); srfTunnel = document.getElementsByTagName("srfTunnelPath").item(0).getTextContent(); } catch (Exception e) { throw e; } connectionData.put("app", app); connectionData.put("tunnel", srfTunnel); connectionData.put("secret", secret); connectionData.put("server", server); connectionData.put("https", (https) ? "True" : "False"); connectionData.put("proxy", srfProxy); connectionData.put("tenant", tenant); return connectionData; } catch (ParserConfigurationException e) { logger.print(e.getMessage()); logger.print("\n\r"); } catch (SAXException | IOException e) { logger.print(e.getMessage()); } return null; }
From source file:com.sammyun.util.DateUtil.java
/** * ?? ??? 2012-01-01?//from w ww . ja va 2 s . c o m * * @param date ? YY-MM * @param isEnd ? * @return * @see [?#?#?] */ public static String parseEarlyEndMonth(String date, boolean isEnd) { // ? if (!isEnd) { return date.concat("-01"); } else { String[] yearMonths = date.split("-"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, Integer.valueOf(yearMonths[0])); cal.set(Calendar.MONTH, Integer.valueOf(yearMonths[1]) - 1); // ? Integer maxDate = cal.getActualMaximum(Calendar.DATE); return date.concat("-".concat(maxDate.toString())); } }
From source file:com.globalsight.util.file.XliffFileUtil.java
/** * Generate absolute path according with specified relative path * // w ww . ja va2 s. c o m * @param p_relativePath * The relative path * @return String Absolute path * * @version 1.0 * @since 8.2.2 */ private static String generateAbsolutePath(String p_relativePath) { String baseCxeDirPath = AmbFileStoragePathUtils.getCxeDocDirPath(); String path = baseCxeDirPath.concat(File.separator).concat(p_relativePath); return path.replace("/", File.separator); }
From source file:com.ckfinder.connector.utils.FileUtils.java
/** * rename file with double extension./*from w ww. ja v a2 s.c om*/ * @param fileName file name * @return new file name with . replaced with _ (but not last) */ public static String renameFileWithBadExt(final ResourceType type, final String fileName) { if (type == null || fileName == null) { return null; } if (fileName.indexOf('.') == -1) { return fileName; } StringTokenizer tokens = new StringTokenizer(fileName, "."); String cfileName = tokens.nextToken(); String currToken = ""; while (tokens.hasMoreTokens()) { currToken = tokens.nextToken(); if (tokens.hasMoreElements()) { cfileName = cfileName.concat(checkSingleExtension(currToken, type) ? "." : "_"); cfileName = cfileName.concat(currToken); } else { cfileName = cfileName.concat(".".concat(currToken)); } } return cfileName; }