Skip to content

Commit 9a65524

Browse files
stsypanovcl4es
authored andcommittedAug 21, 2022
8290300: Use standard String-joining tools where applicable
Reviewed-by: naoto, rriggs, dfuchs
1 parent f9004fe commit 9a65524

File tree

4 files changed

+6
-18
lines changed

4 files changed

+6
-18
lines changed
 

‎src/java.base/share/classes/java/lang/ProcessBuilder.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import java.util.ArrayList;
3535
import java.util.List;
3636
import java.util.Map;
37-
import java.util.StringJoiner;
3837
import jdk.internal.event.ProcessStartEvent;
3938
import sun.security.action.GetPropertyAction;
4039

@@ -1114,12 +1113,8 @@ private Process start(Redirect[] redirects) throws IOException {
11141113
redirectErrorStream);
11151114
ProcessStartEvent event = new ProcessStartEvent();
11161115
if (event.isEnabled()) {
1117-
StringJoiner command = new StringJoiner(" ");
1118-
for (String s: cmdarray) {
1119-
command.add(s);
1120-
}
11211116
event.directory = dir;
1122-
event.command = command.toString();
1117+
event.command = String.join(" ", cmdarray);
11231118
event.pid = process.pid();
11241119
event.commit();
11251120
}

‎src/java.base/share/classes/java/util/Locale.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import java.text.MessageFormat;
4949
import java.util.concurrent.ConcurrentHashMap;
5050
import java.util.spi.LocaleNameProvider;
51-
import java.util.stream.Collectors;
5251

5352
import jdk.internal.vm.annotation.Stable;
5453

@@ -2335,7 +2334,7 @@ private static String formatList(String[] stringList, String pattern) {
23352334
// If we have no list patterns, compose the list in a simple,
23362335
// non-localized way.
23372336
if (pattern == null) {
2338-
return Arrays.stream(stringList).collect(Collectors.joining(","));
2337+
return String.join(",", stringList);
23392338
}
23402339

23412340
return switch (stringList.length) {

‎src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -1536,11 +1536,7 @@ private void setCookieHeader() throws IOException {
15361536
}
15371537
List<String> l = entry.getValue();
15381538
if (l != null && !l.isEmpty()) {
1539-
StringJoiner cookieValue = new StringJoiner("; ");
1540-
for (String value : l) {
1541-
cookieValue.add(value);
1542-
}
1543-
requests.add(key, cookieValue.toString());
1539+
requests.add(key, String.join("; ", l));
15441540
}
15451541
}
15461542
}

‎src/java.base/windows/classes/sun/nio/fs/WindowsPath.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -704,11 +704,9 @@ public WindowsPath subpath(int beginIndex, int endIndex) {
704704
if (beginIndex >= endIndex)
705705
throw new IllegalArgumentException();
706706

707-
StringBuilder sb = new StringBuilder();
707+
StringJoiner sb = new StringJoiner("\\");
708708
for (int i = beginIndex; i < endIndex; i++) {
709-
sb.append(elementAsString(i));
710-
if (i != (endIndex-1))
711-
sb.append("\\");
709+
sb.add(elementAsString(i));
712710
}
713711
return new WindowsPath(getFileSystem(), WindowsPathType.RELATIVE, "", sb.toString());
714712
}

0 commit comments

Comments
 (0)
Please sign in to comment.