/* Based on example squeezeOut() p 186 Java Programming Language */
   
class TestParseLine {
    public static String parseLine(String from,
                                   char toss,
                                   char replace)
    {
        char[] chars = from.toCharArray();      // convert string to an array
        int len = chars.length;
    
        // loop throught the array, replacing the toss characters
        for( int i=0; i<len; i++ ) {
            if( chars[i] == toss ) {
                chars[i] = replace;
            }
        }
        return new String(chars, 0, len);       // return the parsed string
    }
    
    public static void main(String[] args) {
        String str = "Life,has,been,good,to,me,!";
        System.out.println("Original string: " + str);
        System.out.println("  Parsed string: " + parseLine(str, ',', ' ') );
    }
}
