Here you can find the source of addEscapeCharactersForSpaces(String s)
public static String addEscapeCharactersForSpaces(String s)
//package com.java2s; //License from project: Open Source License public class Main { public static String addEscapeCharactersForSpaces(String s) { String outputString = ""; for (int i = 0; i < s.length(); ++i) { if (s.charAt(i) == ' ') outputString = outputString.concat("\\"); outputString = outputString.concat(s.substring(i, i + 1)); }/*from w w w. ja v a 2s .co m*/ return outputString; } }