1 | public static String makeJavaStringLiteral(String text) { |
2 | if (text == null) return null; |
3 | return "\"" + text |
4 | .replace("\\", "\\\\") |
5 | .replace("\"", "\\\"") |
6 | .replace("\n", "\\n") |
7 | .replace("\r", "\\r") + "\""; |
8 | } |
Snippet is not live.
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
2 comment(s) hidden. show
Snippet ID: | #2000331 |
Snippet name: | makeJavaStringLiteral |
Eternal ID of this version: | #2000331/1 |
Text MD5: | b9396f44d54e82f99280ae331cf3dcd6 |
Author: | stefan |
Category: | |
Type: | New Tinybrain snippet |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-05-04 17:15:04 |
Source code size: | 252 bytes / 8 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 1331 / 913 |
Referenced in: | [show references] |