|
19 | 19 | import java.io.IOException; |
20 | 20 | import java.io.OutputStream; |
21 | 21 | import java.nio.charset.Charset; |
22 | | -import java.util.Locale; |
23 | 22 | import java.util.Map; |
24 | 23 | import java.util.SortedMap; |
25 | 24 | import java.util.TreeMap; |
@@ -127,13 +126,23 @@ public void writeDictionary(final Map<?, ?> m) throws IOException { |
127 | 126 | private static String encode(final String s) { |
128 | 127 | if (s == null) throw new NullPointerException("s cannot be null"); |
129 | 128 |
|
130 | | - return String.format(Locale.ENGLISH, "%d%s%s", s.length(), Bencode.SEPARATOR, s); |
| 129 | + StringBuilder buffer = new StringBuilder(); |
| 130 | + buffer.append(s.length()); |
| 131 | + buffer.append(Bencode.SEPARATOR); |
| 132 | + buffer.append(s); |
| 133 | + |
| 134 | + return buffer.toString(); |
131 | 135 | } |
132 | 136 |
|
133 | 137 | private static String encode(final Number n) { |
134 | 138 | if (n == null) throw new NullPointerException("n cannot be null"); |
135 | 139 |
|
136 | | - return String.format(Locale.ENGLISH, "%s%d%s", Bencode.NUMBER, n.longValue(), Bencode.TERMINATOR); |
| 140 | + StringBuilder buffer = new StringBuilder(); |
| 141 | + buffer.append(Bencode.NUMBER); |
| 142 | + buffer.append(n.longValue()); |
| 143 | + buffer.append(Bencode.TERMINATOR); |
| 144 | + |
| 145 | + return buffer.toString(); |
137 | 146 | } |
138 | 147 |
|
139 | 148 | private static String encode(final Iterable<?> l) { |
|
0 commit comments