List of usage examples for java.lang String replace
public String replace(CharSequence target, CharSequence replacement)
From source file:de.tudarmstadt.lt.nlkg.EvaluatePreds.java
static boolean predictEntailingContainedInTopEntries(DT dt, String pred_l, String pred_r) { pred_l = pred_l.replace('X', '\0').replace('Y', '\0').trim().replace(' ', '_'); pred_r = pred_r.replace('X', '\0').replace('Y', '\0').trim().replace(' ', '_'); DT.Entry e = dt.get(pred_l, 200);/*from ww w .jav a 2 s . c o m*/ for (Word w : e) if (pred_r.equals(w.word)) return true; return false; }
From source file:io.cloudslang.content.utils.OtherUtilities.java
/** * Change the from windows line ending in unix line ending * * @param string the string in which to change the line ending * @return a new string with the line ending changed from windows to unix *//*from w w w. jav a 2s. com*/ @NotNull public static String changeNewLineFromWindowsToUnix(@NotNull final String string) { return string.replace("\r\n", "\n"); }
From source file:io.cloudslang.content.utils.OtherUtilities.java
/** * Change the from unix line ending in windows line ending * * @param string the string in which to change the line ending * @return a new string with the line ending changed from unix to windows *///from w ww .ja v a 2s.co m @NotNull public static String changeNewLineFromUnixToWindows(@NotNull final String string) { return string.replace("\n", "\r\n"); }
From source file:Main.java
/** * Parses XML datetime object to Date object * * @param xmlDateTime XML Datetime as a String * @return Datetime object/*w w w.ja v a 2 s. com*/ * @throws ParseException if Parsing exception occurred */ public static Date parseXmlDateTime(String xmlDateTime) { Date parsedDate = new Date(); try { xmlDateTime = xmlDateTime.replace("Z", "+0000"); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault()); parsedDate = dateFormat.parse(xmlDateTime); return parsedDate; } catch (ParseException e) { e.printStackTrace(); } return parsedDate; }
From source file:Main.java
/** * Convert Base64 string to byte array./*from ww w . java 2 s.c o m*/ * * @param input * Base64 string. * @return Converted byte array. */ public static byte[] fromBase64(final String input) { String tmp = input.replace("\r\n", ""); if (tmp.length() % 4 != 0) { throw new IllegalArgumentException("Invalid base64 input"); } int len = (tmp.length() * 3) / 4; int pos = tmp.indexOf('='); if (pos > 0) { len -= tmp.length() - pos; } byte[] decoded = new byte[len]; char[] inChars = new char[4]; int j = 0; int[] b = new int[4]; for (pos = 0; pos != tmp.length(); pos += 4) { tmp.getChars(pos, pos + 4, inChars, 0); b[0] = getIndex(inChars[0]); b[1] = getIndex(inChars[1]); b[2] = getIndex(inChars[2]); b[3] = getIndex(inChars[3]); decoded[j++] = (byte) ((b[0] << 2) | (b[1] >> 4)); if (b[2] < 64) { decoded[j++] = (byte) ((b[1] << 4) | (b[2] >> 2)); if (b[3] < 64) { decoded[j++] = (byte) ((b[2] << 6) | b[3]); } } } return decoded; }
From source file:com.ewcms.common.io.HtmlFileUtil.java
public static String normalizePath(String path) { path = path.replace('\\', '/'); path = HtmlStringUtil.replaceEx(path, "../", "/"); path = HtmlStringUtil.replaceEx(path, "./", "/"); if (path.endsWith("..")) path = path.substring(0, path.length() - 2); path = path.replaceAll("/+", "/"); return path;//ww w .jav a 2s. c om }
From source file:Main.java
public static String DecodeHtml(String strInPut) { String Temp = strInPut; // Temp.Replace("<br>", "\r"); // Temp.Replace(" ", " "); Temp = Temp.replace("<", "<"); Temp = Temp.replace(">", ">"); // Temp.Replace("&","&"); Temp = Temp.replace(""", "\""); return Temp;//ww w . j av a2s .c o m }
From source file:Main.java
/** * Given an input class object, return a string which consists of the * class's package name as a pathname, i.e., all dots ('.') are replaced by * slashes ('/'). Neither a leading nor trailing slash is added. The result * could be concatenated with a slash and the name of a resource and fed * directly to {@code ClassLoader.getResource()}. For it to be fed to * {@code Class.getResource} instead, a leading slash would also have * to be prepended to the returned value. * * @param clazz the input class. A {@code null} value or the default * (empty) package will result in an empty string ("") being returned. * @return a path which represents the package name * @see ClassLoader#getResource//from www . j a v a 2 s . c om * @see Class#getResource */ public static String classPackageAsResourcePath(Class<?> clazz) { if (clazz == null) { return ""; } String className = clazz.getName(); int packageEndIndex = className.lastIndexOf(PACKAGE_SEPARATOR); if (packageEndIndex == -1) { return ""; } String packageName = className.substring(0, packageEndIndex); return packageName.replace(PACKAGE_SEPARATOR, PATH_SEPARATOR); }
From source file:Main.java
public static String getParakeetSetupURL(Context context) { String url = getParakeetURL(context); if (url == null) return null; return url.replace("/json.get", "/setcode/2"); }
From source file:se.uu.it.cs.recsys.dataloader.correction.CourseSelectionRecourseCorrecter.java
private static String replaceWrongCourseNameWithCorrect(String line, Map<String, String> wrongToCorrect) { StringBuilder lineCopy = new StringBuilder(line); wrongToCorrect.entrySet().stream().forEach(entry -> { if (lineCopy.toString().contains(entry.getKey())) { String contentCopy = lineCopy.toString(); String replacedCopy = contentCopy.replace(entry.getKey(), entry.getValue()); lineCopy.setLength(0);/*w w w. j a va2 s . c o m*/ lineCopy.append(replacedCopy); } }); return lineCopy.toString(); }