Answer the question
In order to leave comments, you need to log in
Why doesn't the \n substitution work?
System.out.println("GET http://www.example.com/example.js HTTP/1.1\n" +
"Host: www.example.com\n" +
"Proxy-Connection: keep-alive\n" +
"If-Modified-Since: Wed, 06 Jul 2016 07:58:20 GMT\n\n".replaceAll("\n", "E"));
Pattern pattern = Pattern.compile("\n", Pattern.MULTILINE);
System.out.println(pattern.matcher("GET http://www.example.com/example.js HTTP/1.1\n" +
"Host: www.example.com\n" +
"Proxy-Connection: keep-alive\n" +
"If-Modified-Since: Wed, 06 Jul 2016 07:58:20 GMT\n\n").replaceAll("E"));
Answer the question
In order to leave comments, you need to log in
I'm not a javist in its purest form, but I know that .replace() is performed first and then "+"
use StringBuffer
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question