Use StringBuilder for string concatenation in loop

This commit is contained in:
Martin Fietz 2018-01-14 18:01:31 +01:00
parent e44a54c965
commit 919ee63c3c

View File

@ -1136,16 +1136,16 @@ public abstract class NanoHTTPD {
String pname = disposition.get("name");
pname = pname.substring(1, pname.length() - 1);
String value = "";
StringBuilder value = new StringBuilder();
if (item.get("content-type") == null) {
while (mpline != null && !mpline.contains(boundary)) {
mpline = in.readLine();
if (mpline != null) {
int d = mpline.indexOf(boundary);
if (d == -1) {
value += mpline;
value.append(mpline);
} else {
value += mpline.substring(0, d - 2);
value.append(mpline.substring(0, d - 2));
}
}
}
@ -1156,13 +1156,13 @@ public abstract class NanoHTTPD {
int offset = stripMultipartHeaders(fbuf, bpositions[boundarycount - 2]);
String path = saveTmpFile(fbuf, offset, bpositions[boundarycount - 1] - offset - 4);
files.put(pname, path);
value = disposition.get("filename");
value = value.substring(1, value.length() - 1);
value = new StringBuilder(disposition.get("filename"));
value = new StringBuilder(value.substring(1, value.length() - 1));
do {
mpline = in.readLine();
} while (mpline != null && !mpline.contains(boundary));
}
parms.put(pname, value);
parms.put(pname, value.toString());
}
}
} catch (IOException ioe) {