Here you can find the source of convertString(String label)
public static final String convertString(String label)
//package com.java2s; /*//from ww w .j a v a 2s.c o m * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { /** * Escape all occurences of newline chars '\n', quotes \", etc. */ public static final String convertString(String label) { char[] ch = label.toCharArray(); StringBuffer buf = new StringBuffer(); for (int i = 0; i < ch.length; i++) { switch (ch[i]) { case '\n': buf.append("\\n"); break; case '\r': buf.append("\\r"); break; case '\"': buf.append("\\\""); break; case '\'': buf.append("\\'"); break; case '\\': buf.append("\\\\"); break; default: buf.append(ch[i]); break; } } return buf.toString(); } }