Here you can find the source of toInternalString(String s)
public static String toInternalString(String s)
//package com.java2s; public class Main { public static String toInternalString(String s) { String newString;//from w w w . j a va 2 s.c o m if (s.charAt(0) == '"') { int len = s.length(); int bufferLen = 0; char[] buffer = new char[len]; for (int i = 1; i < len - 1; ++i) { char c = s.charAt(i); if (c == '\\') { //ESCA-JAVA0119 ++i; c = s.charAt(i); if (c == 'n') { c = '\n'; } else if (c == 'r') { // simply discard '\r' continue; } } buffer[bufferLen] = c; ++bufferLen; } newString = new String(buffer, 0, bufferLen); } else { newString = s; } return newString.intern(); } }