code: public void printJavaChar(char ch) throws IOException
    {
      switch (ch) {
      case '\\':
        _os.print("\\\\");
        break;
      case '\n':
        _os.print("\\n");
        break;
      case '\r':
        _os.print("\\r");
        break;
      case '\'':
        _os.print("\\'");
        break;
      default:
        _os.print(ch);
      }
    }
docs: Prints a Java escaped string