Guest User

Untitled

a guest
Nov 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. package net.nixill;
  2.  
  3. public class Quine {
  4. static final String SOURCE_CODE =
  5. "package net.nixill;\n"+
  6. "\n"+
  7. "public class Quine {\n"+
  8. " static final String SOURCE_CODE =\n"+
  9. "\"%s\";\n"+
  10. " \n"+
  11. " public static String escape(String in) {\n"+
  12. " in = in.replaceAll(\"\\\\\\\\\", \"\\uE000\")\n"+
  13. " .replaceAll(\"\\\\\\\"\", \"\\\\\\\\\\\\\\\"\")\n"+
  14. " .replaceAll(\"\\n\", \"\\\\\\\\n\\\\\\\"+\\\\\\n\\\\\\\"\")\n"+
  15. " .replaceAll(\"\\uE000\", \"\\\\\\\\\\\\\\\\\");\n"+
  16. " return in;\n"+
  17. " }\n"+
  18. " \n"+
  19. " public static void main(String[] args) {\n"+
  20. " System.out.print(String.format(SOURCE_CODE, escape(SOURCE_CODE)));\n"+
  21. " }\n"+
  22. "}";
  23.  
  24. public static String escape(String in) {
  25. in = in.replaceAll("\\\\", "\uE000")
  26. .replaceAll("\\\"", "\\\\\\\"")
  27. .replaceAll("\n", "\\\\n\\\"+\\\n\\\"")
  28. .replaceAll("\uE000", "\\\\\\\\");
  29. return in;
  30. }
  31.  
  32. public static void main(String[] args) {
  33. System.out.print(String.format(SOURCE_CODE, escape(SOURCE_CODE)));
  34. }
  35. }
Add Comment
Please, Sign In to add comment