|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2018 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2025 IBM Corporation and others. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials |
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0 |
|
20 | 20 | import java.io.IOException; |
21 | 21 | import java.io.InputStream; |
22 | 22 | import java.io.InputStreamReader; |
| 23 | +import java.util.stream.Collectors; |
23 | 24 |
|
24 | 25 | import org.eclipse.swt.SWT; |
25 | 26 | import org.eclipse.swt.SWTError; |
@@ -118,17 +119,13 @@ void createExampleWidgets () { |
118 | 119 | } else if (lastText != null) { |
119 | 120 | browser.setText(lastText); |
120 | 121 | } else { |
121 | | - StringBuilder sb= new StringBuilder(300); |
122 | | - |
| 122 | + String text= ""; |
123 | 123 | try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html"); |
124 | 124 | BufferedReader br = new BufferedReader(new InputStreamReader(htmlStream))) { |
125 | | - int read = 0; |
126 | | - while ((read = br.read()) != -1) |
127 | | - sb.append((char) read); |
| 125 | + text= br.lines().collect(Collectors.joining("\n")); |
128 | 126 | } catch (IOException e) { |
129 | 127 | log(e.getMessage()); |
130 | 128 | } |
131 | | - String text= sb.toString(); |
132 | 129 | browser.setText(text); |
133 | 130 | } |
134 | 131 | lastText = lastUrl = null; |
@@ -229,16 +226,6 @@ void disposeExampleWidgets () { |
229 | 226 | super.disposeExampleWidgets(); |
230 | 227 | } |
231 | 228 |
|
232 | | - public static String getContents(InputStream in) throws IOException { |
233 | | - StringBuilder sb= new StringBuilder(300); |
234 | | - try (BufferedReader br= new BufferedReader(new InputStreamReader(in))) { |
235 | | - int read= 0; |
236 | | - while ((read= br.read()) != -1) |
237 | | - sb.append((char) read); |
238 | | - } |
239 | | - return sb.toString(); |
240 | | - } |
241 | | - |
242 | 229 | /** |
243 | 230 | * Gets the list of custom event names. |
244 | 231 | * |
|
0 commit comments