public static String makeJavaStringLiteral(String text) {
    if (text == null) return null;
    return "\"" + text
      .replace("\\", "\\\\")
      .replace("\"", "\\\"")
      .replace("\n", "\\n")
      .replace("\r", "\\r") + "\"";
  }
Snippet is not live.
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
| ID | Author/Program | Comment | Date | |
|---|---|---|---|---|
| 833 | #1000610 | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { public static String makeJavaStringLiteral(String text) { if (text == null) return null; return "\"" + text .replace("\\", "\\\\") .replace("\"", "\\\"") .replace("\n", "\\n") .replace("\r", "\\r") + "\""; } }} | 2015-08-19 22:47:39 | delete | 
| 809 | #1000604 (pitcher) | 2015-08-18 00:07:22 | 
| 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: | 1548 / 939 | 
| Referenced in: | [show references] |