List of usage examples for java.lang String replace
public String replace(CharSequence target, CharSequence replacement)
From source file:Main.java
public static String escapeCDATA(String cdata) { if (cdata == null) return ""; return cdata.replace("]]>", "]]]><![CDATA[]>"); }
From source file:Main.java
public static String findDateWithFormat(String findDate, String format) { findDate = findDate.replace(" ", "").replace("-", "").replace(":", "").replace("/", "").replace(".", ""); Locale currentLocale = new Locale("KOREAN", "KOREA"); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss", currentLocale); SimpleDateFormat returnFormatter = new SimpleDateFormat(format, currentLocale); String returnValue = ""; try {//from w ww . ja va 2 s . c o m Date fDate = formatter.parse(findDate); returnValue = returnFormatter.format(fDate); } catch (ParseException e) { e.printStackTrace(); } return returnValue; }
From source file:Main.java
private static String getImageName(String componentClassName, String creationId) { String imageName = componentClassName.replace('.', '/'); return creationId == null ? imageName : imageName + "_" + creationId; }
From source file:Main.java
public static void visitRecursively(Node node, BufferedWriter bw) throws Exception { NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { // get child node Node childNode = list.item(i); if (childNode.getNodeType() == Node.TEXT_NODE) { System.out.println("Found Node: " + childNode.getNodeName() + " - with value: " + childNode.getNodeValue() + " Node type:" + childNode.getNodeType()); String nodeValue = childNode.getNodeValue(); nodeValue = nodeValue.replace("\n", "").replaceAll("\\s", ""); if (!nodeValue.isEmpty()) { System.out.println(nodeValue); bw.write(nodeValue);/*w ww . java 2 s.com*/ bw.newLine(); } } visitRecursively(childNode, bw); } }
From source file:Main.java
/** add serialized helper */ private static void addSerialized(StringBuilder result, String key, Object value) { result.append(key.replace(SERIALIZATION_SEPARATOR, SEPARATOR_ESCAPE)).append(SERIALIZATION_SEPARATOR); if (value instanceof Integer) { result.append('i').append(value); } else if (value instanceof Double) { result.append('d').append(value); } else if (value instanceof Long) { result.append('l').append(value); } else if (value instanceof String) { result.append('s').append(value.toString().replace(SERIALIZATION_SEPARATOR, SEPARATOR_ESCAPE)); } else if (value instanceof Boolean) { result.append('b').append(value); } else {/* w w w . ja v a 2 s .c o m*/ throw new UnsupportedOperationException(value.getClass().toString()); } result.append(SERIALIZATION_SEPARATOR); }
From source file:Main.java
public static String getKey(String baseHref, String displayName, long exportBatchId) { displayName = displayName.replace("\\", "/"); int index = displayName.indexOf("/", baseHref.length() + 2); String key = exportBatchId + displayName.substring(0, index); return key;/*from w w w .ja va2s . co m*/ }
From source file:Main.java
public static String isbnClear(String isbn) { if (isbn == null) return null; return isbn.replace("-", ""); }
From source file:Main.java
/** * Transform ISO 8601 string to Calendar. *///from ww w.j a va 2 s . com public static Date stringToDate(final String iso8601string) { try { String s = iso8601string.replace("Z", "+00:00"); s = s.substring(0, 22) + s.substring(23); return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US).parse(s); } catch (Exception e) { return null; } }
From source file:Main.java
public static String cnpjClear(String cnpj) { if (cnpj == null) return null; return cnpj.replace(".", "").replace("-", "").replace("/", ""); }
From source file:Main.java
public static String getClassFile(String name) { StringBuffer sb = new StringBuffer(name); name = name.replace('.', File.separatorChar) + ".class"; sb.append(File.separator + name); return sb.toString(); }