List of usage examples for java.lang String replace
public String replace(CharSequence target, CharSequence replacement)
From source file:com.esri.geoevent.test.performance.utils.MessageUtils.java
public static String unescapeNewLineCharacters(String data) { if (StringUtils.isEmpty(data)) return null; String replacedData = data.replace(CRNL_SEPERATOR, DEFAULT_CRNL_SEPERATOR); replacedData = replacedData.replace(CR_SEPERATOR, DEFAULT_CR_SEPERATOR); replacedData = replacedData.replace(NL_SEPERATOR, DEFAULT_NL_SEPERATOR); return replacedData; }
From source file:Main.java
/** * Fix problems in the URIs (spaces for instance). * * @param uri//from w w w. j av a 2 s.c om * The original URI. * @return The corrected URI. */ private static String fixUri(String uri) { // handle platform dependent strings String path = uri.replace(java.io.File.separatorChar, '/'); // Windows fix if (path.length() >= 2) { final char ch1 = path.charAt(1); // change "C:blah" to "/C:blah" if (ch1 == ':') { final char ch0 = Character.toUpperCase(path.charAt(0)); if (ch0 >= 'A' && ch0 <= 'Z') { path = "/" + path; } } // change "//blah" to "file://blah" else if (ch1 == '/' && path.charAt(0) == '/') { path = "file:" + path; } } // replace spaces in file names with %20. // Original comment from JDK5: the following algorithm might not be // very performant, but people who want to use invalid URI's have to // pay the price. final int pos = path.indexOf(' '); if (pos >= 0) { final StringBuilder sb = new StringBuilder(path.length()); // put characters before ' ' into the string builder for (int i = 0; i < pos; i++) { sb.append(path.charAt(i)); } // and %20 for the space sb.append("%20"); // for the remaining part, also convert ' ' to "%20". for (int i = pos + 1; i < path.length(); i++) { if (path.charAt(i) == ' ') { sb.append("%20"); } else { sb.append(path.charAt(i)); } } return sb.toString(); } return path; }
From source file:Main.java
public static String getFilePath(File dirPath, String fileName) { try {//from www .j ava 2s . co m String filePath = dirPath.getAbsolutePath() + File.separator + URLEncoder.encode(fileName.replace("*", ""), "UTF-8"); return filePath; } catch (final UnsupportedEncodingException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String cleanIdentifier(String id) { String cleanId = id; for (String s : ILLEGAL_ID_CHARACTERS) { if (cleanId.contains(s)) cleanId = cleanId.replace(s, ""); }/* w ww . j ava 2s . co m*/ return cleanId; }
From source file:com.centeractive.ws.server.util.TestUtils.java
public static String formatContextPath(int testServiceId, Binding binding) { String namespace = binding.getQName().getNamespaceURI(); namespace = namespace.replace("http://", ""); namespace = namespace.replace("https://", ""); namespace = namespace.replace("www.", ""); namespace = namespace.replace("www", ""); namespace = namespace.replaceAll("[^\\p{L}]", "_"); return "/service" + formatServiceId(testServiceId) + "_" + namespace + "_" + binding.getQName().getLocalPart(); }
From source file:com.fizzed.blaze.internal.DependencyHelper.java
/** * Dependencies outputted by the maven dependency plugin are of this form * groupId:artifactId:type:version// w ww . j av a2 s .c o m * and we actually want groupId:artifactId:type:version * @param dependency * @return */ static public String cleanMavenDependencyLine(String dependency) { return dependency.replace(":jar:", ":"); }
From source file:Main.java
public static void composeEmail(Context context, String email, String subject, String body) { try {//from ww w.j a va 2s. c o m String url = "mailto:"; if (email != null) { url += email; } url += "?"; if (subject != null) { String subjectEncoded = URLEncoder.encode(subject, "UTF-8"); subjectEncoded = subjectEncoded.replace("+", "%20"); url += "subject=" + subjectEncoded; } if (body != null) { if (subject != null) { url += "&"; } String bodyEncoded = URLEncoder.encode(body, "UTF-8"); bodyEncoded = bodyEncoded.replace("+", "%20"); url += "body=" + bodyEncoded; } viewURL(context, url); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.acc.storefront.util.MetaSanitizerUtil.java
/** * Removes all HTML tags and double quotes and returns a String * //from ww w .ja v a 2 s .c o m * @param description * Description to be sanitized * @return String object */ public static String sanitizeDescription(final String description) { if (StringUtils.isNotEmpty(description)) { final String clean = Jsoup.parse(description).text(); return clean.replace("\"", ""); } else { return ""; } }
From source file:com.hangum.tadpole.engine.manager.internal.map.SQLMap.java
/** * DB ?? .//ww w. j av a2 s . com * @param dbInfo * @return * @throws Exception */ private static String getConfig(UserDBDAO dbInfo) throws Exception { String config = getFileToString(dbInfo.getDBDefine().getLocation()); config = config.replace(URL, StringEscapeUtils.escapeXml(dbInfo.getUrl())); config = config.replace(USERNAME, StringEscapeUtils.escapeXml(dbInfo.getUsers())); config = config.replace(PASSWORD, StringEscapeUtils.escapeXml(dbInfo.getPasswd())); return config; }
From source file:com.shelfmap.stepsfinder.CandidateStepsFactory.java
public static List<Class<?>> findStepsClasses(Class<?> embedderClass) { final String classPath = packagePath(embedderClass); List<String> paths = new StoryFinder().findPaths(codeLocationFromParentPackage(embedderClass).getFile(), asList("**/*.class"), null); transform(paths, new Transformer() { @Override//from ww w.j a v a 2 s . c o m public Object transform(Object input) { return classPath + (removeEnd((String) input, ".class")); } }); List<Class<?>> classes = new ArrayList<Class<?>>(); for (String path : paths) { final String className = path.replace("/", "."); try { Class<?> clazz = Class.forName(className); if (clazz.isAnnotationPresent(Steps.class)) { classes.add(clazz); } } catch (ClassNotFoundException ex) { LOGGER.error("Could not load the class: " + className); } } return classes; }