diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java index a46f1693e96..a2cf561a9db 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -16,10 +16,9 @@ import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; -import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; @@ -118,18 +117,12 @@ void createExampleWidgets () { } else if (lastText != null) { browser.setText(lastText); } else { - StringBuilder sb= new StringBuilder(300); - - try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html"); - BufferedReader br = new BufferedReader(new InputStreamReader(htmlStream))) { - int read = 0; - while ((read = br.read()) != -1) - sb.append((char) read); + try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html")) { + browser.setText( new String (htmlStream.readAllBytes(), StandardCharsets.UTF_8)); } catch (IOException e) { log(e.getMessage()); + browser.setText("Loading failed, see log for details!"); } - String text= sb.toString(); - browser.setText(text); } lastText = lastUrl = null; } @@ -229,16 +222,6 @@ void disposeExampleWidgets () { super.disposeExampleWidgets(); } - public static String getContents(InputStream in) throws IOException { - StringBuilder sb= new StringBuilder(300); - try (BufferedReader br= new BufferedReader(new InputStreamReader(in))) { - int read= 0; - while ((read= br.read()) != -1) - sb.append((char) read); - } - return sb.toString(); - } - /** * Gets the list of custom event names. * diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/browser-content.html b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/browser-content.html index 3fb059c6b3d..56590ad4c1e 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/browser-content.html +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/browser-content.html @@ -1,10 +1,11 @@ + SWT Browser

About SWT Browser

-

You are looking at HTML content in a Browser widget. +

You are looking at HTML content in a Browser widget.

+

About SWT

For more information on SWT, including the Widget Gallery, Snippets, Examples, FAQ, Tools, Documentation