Here you can find the source of QuoteValue(String str)
Parameter | Description |
---|---|
str | A string object. |
public static String QuoteValue(String str)
//package com.java2s; public class Main { /**//from ww w. ja v a2 s . com * Quotes a string according to RFC 5322 rules. * @param str A string object. * @return A string object. */ public static String QuoteValue(String str) { StringBuilder builder = new StringBuilder(); builder.append('"'); for (int i = 0; i < str.length(); ++i) { if (str.charAt(i) == '\\' || str.charAt(i) == '"') { builder.append('\\'); builder.append(str.charAt(i)); } else { builder.append(str.charAt(i)); } } builder.append('"'); return builder.toString(); } }