Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1005966 // quoteToPrintWriter

JavaX fragment (include)

static void quoteToPrintWriter(S s, PrintWriter out) {
  if (s == null) { out.print("null"); ret; }
  out.print('"');
  int l = s.length();
  for (int i = 0; i < l; i++) {
    char c = s.charAt(i);
    if (c == '\\' || c == '"') {
      out.print('\\'); out.print(c);
    } else if (c == '\r')
      out.print("\\r");
    else if (c == '\n')
      out.print("\\n");
    else if (c == '\0')
      out.print("\\0");
    else
      out.print(c);
  }
  out.print('"');
}

Author comment

Began life as a copy of #1005595

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005966
Snippet name: quoteToPrintWriter
Eternal ID of this version: #1005966/2
Text MD5: df90ff15f6409cca33c821bbf89755db
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-02 23:58:03
Source code size: 484 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 520 / 699
Version history: 1 change(s)
Referenced in: [show references]