|
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 |
|
16 | 16 |
|
17 | 17 | import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; |
18 | 18 |
|
19 | | -import java.io.BufferedReader; |
20 | 19 | import java.io.IOException; |
21 | 20 | import java.io.InputStream; |
22 | | -import java.io.InputStreamReader; |
| 21 | +import java.nio.charset.StandardCharsets; |
23 | 22 |
|
24 | 23 | import org.eclipse.swt.SWT; |
25 | 24 | import org.eclipse.swt.SWTError; |
@@ -118,18 +117,12 @@ void createExampleWidgets () { |
118 | 117 | } else if (lastText != null) { |
119 | 118 | browser.setText(lastText); |
120 | 119 | } else { |
121 | | - StringBuilder sb= new StringBuilder(300); |
122 | | - |
123 | | - try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html"); |
124 | | - BufferedReader br = new BufferedReader(new InputStreamReader(htmlStream))) { |
125 | | - int read = 0; |
126 | | - while ((read = br.read()) != -1) |
127 | | - sb.append((char) read); |
| 120 | + try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html")) { |
| 121 | + browser.setText( new String (htmlStream.readAllBytes(), StandardCharsets.UTF_8)); |
128 | 122 | } catch (IOException e) { |
129 | 123 | log(e.getMessage()); |
| 124 | + browser.setText("Loading failed, see log for details!"); |
130 | 125 | } |
131 | | - String text= sb.toString(); |
132 | | - browser.setText(text); |
133 | 126 | } |
134 | 127 | lastText = lastUrl = null; |
135 | 128 | } |
@@ -229,16 +222,6 @@ void disposeExampleWidgets () { |
229 | 222 | super.disposeExampleWidgets(); |
230 | 223 | } |
231 | 224 |
|
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 | 225 | /** |
243 | 226 | * Gets the list of custom event names. |
244 | 227 | * |
|
0 commit comments