List of usage examples for java.lang String concat
public String concat(String str)
From source file:com.stgmastek.core.comm.main.StartCoreCommunication.java
static void getBundleDetails() { strBundleDetailsArray_ = new String[] { "Unknown", "Unknown", "Unknown", Integer.MIN_VALUE + "", Integer.MIN_VALUE + "", Integer.MIN_VALUE + "" }; String localFile = StartCoreCommunication.class.getProtectionDomain().getCodeSource().getLocation() .toString();//from w w w.ja v a2 s . com localFile = localFile.concat("!/"); String tmpString = "jar:"; String localJarFileString = tmpString.concat(localFile); URL localJarFileURL; try { localJarFileURL = new URL(localJarFileString); JarURLConnection localJarFile = (JarURLConnection) localJarFileURL.openConnection(); Manifest mf = localJarFile.getManifest(); Attributes attributes = mf.getMainAttributes(); strBundleDetailsArray_[0] = (String) attributes.getValue("Bundle-Name"); strBundleDetailsArray_[1] = (String) attributes.getValue("Bundle-Version"); strBundleDetailsArray_[2] = (String) attributes.getValue("Bundled-On"); strBundleDetailsArray_[3] = (String) attributes.getValue("Major-Version"); strBundleDetailsArray_[4] = (String) attributes.getValue("Minor-Version"); strBundleDetailsArray_[5] = (String) attributes.getValue("Build-Number"); } catch (MalformedURLException e) { // do nothing } catch (FileNotFoundException fnfe) { // do nothing } catch (IOException ioe) { // do nothing } }
From source file:eu.optimis.mi.aggregator.util.ConfigManager.java
public static String getConfigFilePath(String configFile) throws IOException { String optimisHome = System.getenv("OPTIMIS_HOME"); if (optimisHome == null) { optimisHome = "/opt/optimis"; log.warn("No environment variable OPTIMIS_HOME. Using default /opt/optimis."); }/*w w w. j a va 2s.com*/ File fileObject = new File(optimisHome.concat(configFile)); //If not exists, copy property files from the source code to %OPTIMIS_HOME% if (!fileObject.exists()) { createDefaultConfigFile(fileObject); } return optimisHome.concat(configFile); }
From source file:org.helianto.core.test.AbstractIntegrationTest.java
/** * Generate a not repeatable key of a given size. *//*w w w . j a va2 s .c o m*/ public static String generateKey(int size, int index) { String localKey = index + "-" + generateKey(); while (localKey.length() != size) { if (localKey.length() > size) { localKey = localKey.substring(localKey.length() - size, localKey.length()); } else if (localKey.length() < size) { localKey = localKey.concat(localKey); } } return localKey; }
From source file:com.erudika.para.utils.ValidationUtils.java
/** * Validates objects using Hibernate Validator. * @param content an object to be validated * @return a list of error messages or empty if object is valid *//*from w w w . j a va 2s . co m*/ public static String[] validateObject(ParaObject content) { if (content == null) { return new String[] { "Object cannot be null." }; } ArrayList<String> list = new ArrayList<String>(); try { for (ConstraintViolation<ParaObject> constraintViolation : getValidator().validate(content)) { String prop = "'".concat(constraintViolation.getPropertyPath().toString()).concat("'"); list.add(prop.concat(" ").concat(constraintViolation.getMessage())); } } catch (Exception e) { logger.error(null, e); } return list.toArray(new String[] {}); }
From source file:cc.gospy.core.util.StringHelper.java
@Experimental public static String toRelativeUrl(final String protocol, final String host, final String parentUrl, final String targetUrl) { if (parentUrl.equals(targetUrl) || parentUrl.equals(targetUrl.concat("/"))) { return parentUrl; }/*from w w w . j a v a 2 s. c om*/ String pattern = protocol.concat("://").concat(host).concat("/"), target = targetUrl; String parent = parentUrl.length() == pattern.length() - 1 ? parentUrl.concat("/") : parentUrl; String parentDir = parent.substring(pattern.length() - 1, parent.lastIndexOf('/')); StringBuilder relativeUrl = new StringBuilder(); if (target.matches("http://.*|https://.*|//.*|/.*")) { target = target.startsWith("//") ? "http:".concat(target) : target; target = target.startsWith("/") ? pattern.concat(target.substring(1)) : target; if (!target.startsWith(pattern)) { return null; // target url crosses domain } } String res = target.substring(target.lastIndexOf('/') + 1); String targetDir = target.substring(pattern.length() - 1, target.lastIndexOf('/')); while (true) { if (0 == Math.min(parentDir.length(), targetDir.length()) || parentDir.charAt(0) != targetDir.charAt(0)) { break; } if (parentDir.charAt(0) == '/' && targetDir.charAt(0) == '/') { parentDir = parentDir.substring(1); targetDir = targetDir.substring(1); continue; } if (parentDir.indexOf('/') != -1 && targetDir.indexOf('/') != -1) { String s = parentDir.substring(0, parentDir.indexOf('/')); if (s.equals(targetDir.substring(0, targetDir.indexOf('/')))) { parentDir = parentDir.substring(s.length()); targetDir = targetDir.substring(s.length()); } else { break; } } else { break; } } int depth = parentDir.length() != 0 ? parentDir.split("/").length : 0; depth = targetDir.length() != 0 ? depth : depth - 1; while (depth-- > 0) { relativeUrl.append("../"); } relativeUrl.append(targetDir.startsWith("/") ? targetDir.substring(1) : targetDir); return (parentDir.length() == 0 ? "./" : "").concat(relativeUrl.toString()) .concat(targetDir.length() == 0 ? "" : "/").concat(res); }
From source file:com.thoughtworks.gauge.util.GaugeUtil.java
public static String getOutput(InputStream stream, String lineSeparator) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(stream)); String lastProcessStdout = ""; String line;/*from www .j av a2 s .c om*/ while ((line = br.readLine()) != null) if (!line.startsWith("[DEPRECATED]")) lastProcessStdout = lastProcessStdout.concat(line).concat(lineSeparator); return lastProcessStdout; }
From source file:com.sds.acube.ndisc.xnapi.XNApiUtils.java
/** * ByteBuffer? ? padding// ww w .ja v a2s . com * * @param data * ? * @param size * ? * @return padding ? ? */ public static String getFormatString(String data, int size) { if (data.length() > size) { data = data.substring(0, size); } else { data = data.concat(RCV_BUFFER_STR.substring(data.length())); } return data; }
From source file:demo.RxJavaTransformer.java
private static String combine(List<String> data) { String result = ""; for (String d : data) { result = result.concat(":").concat(d); }//w w w . j a va2 s. c o m return result; }
From source file:Main.java
public static String fillSpaceByByte(String str, int length) { byte[] strbyte = str.getBytes(); int strLength = strbyte.length; if (strLength >= length) { return str; }/*from w w w . j av a 2 s. co m*/ StringBuffer spaceBuffer = new StringBuffer(); for (int i = 0; i < (length - strLength); i++) { spaceBuffer.append(" "); } return str.concat(spaceBuffer.toString()); }
From source file:es.juntadeandalucia.panelGestion.negocio.utiles.Geoserver.java
public static String getWMSGetCapabilitiesUrl(String wmsUrl) { GeoserverVO geoserverVO = Utils.getGeoserverVOByURL(wmsUrl); String wmsGetCapabilities = wmsUrl.concat("service=WMS&request=GetCapabilities&version=") .concat(geoserverVO.getGeoserverWMSVersion()); return wmsGetCapabilities; }