javastringescapeutils

use string escape utility function with using Apache common library (StringEscapeUtils)


I want to know if there is any other way to output the same results without using Apache common Library. I did this way but i need to know how to do it without any external imports. Thanks a lot ahead.

import org.apache.commons.lang.StringEscapeUtils;
public class Solution
{
    public static void main(String[] args)
    {
        String path="\"C:\\Program Files\\Java\\jdk1.7.0\\bin\"";
        String pathJava = StringEscapeUtils.escapeJava(path);
        System.out.println("It's Window path: "+ path);
        System.out.println("It's java path: "+pathJava);

    }
}

Solution

  • Why not checkout the original source here to understand how apache's StringEscapeUtils does it?