|
14 | 14 | import java.io.InputStream; |
15 | 15 | import java.nio.charset.StandardCharsets; |
16 | 16 | import java.util.Objects; |
17 | | -import java.util.regex.Matcher; |
18 | 17 | import java.util.regex.Pattern; |
19 | 18 | import javax.xml.stream.XMLStreamException; |
20 | 19 |
|
@@ -66,10 +65,10 @@ public void write(XmlWriter writer) throws XmlWriteException { |
66 | 65 | } |
67 | 66 |
|
68 | 67 | /** |
69 | | - * A matcher, created only once, reusable to match the XML declaration with any attributes. |
| 68 | + * A pattern, created only once, reusable to match the XML declaration with any attributes. |
70 | 69 | * Non-greedy, so we do not interfere with any XML processing instructions following. |
71 | 70 | */ |
72 | | - private static final Matcher xmlDeclaration = Pattern.compile("<\\?xml .*?\\?>").matcher(""); |
| 71 | + private static final Pattern xmlDeclaration = Pattern.compile("<\\?xml .*?\\?>"); |
73 | 72 |
|
74 | 73 | protected void writeXml(XmlWriter writer) throws IOException { |
75 | 74 |
|
@@ -109,7 +108,7 @@ protected void writeXml(XmlWriter writer) throws IOException { |
109 | 108 |
|
110 | 109 | String firstChars = new String(bytes, StandardCharsets.UTF_8); |
111 | 110 | // match the start with the compiled regex and replace with nothing when matching. |
112 | | - firstChars = xmlDeclaration.reset(firstChars).replaceFirst(""); |
| 111 | + firstChars = xmlDeclaration.matcher(firstChars).replaceFirst(""); |
113 | 112 |
|
114 | 113 | // write the chars to the output stream |
115 | 114 | writer.getOutputStream().write(firstChars.getBytes(StandardCharsets.UTF_8)); |
|
0 commit comments