String (String value) { StringBuilder buffer = new StringBuilder(value.length()); int length = value.length(); int last = length - 1; for (int i = 0; i < length; i++) { char ch = value.charAt(i); if (ch == '\\' && i != last) { i++; ch = value.charAt(i); if (ch == 'n') { buffer.append('\n'); } else if (ch == 'r') { buffer.append('\n'); } else if (ch == '\\') { buffer.append('\\'); } else { buffer.append('\\'); buffer.append(ch); } } else { buffer.append(ch); } } return buffer.toString(); }