There is a small problem about calling the browser and temporary files.
In this way, an HTML document is downloaded from the Internet and stored in the temporary files folder:
HttpURLConnection i2 = (HttpURLConnection) new URL("...").openConnection(); ... BufferedReader i3 = new BufferedReader(new InputStreamReader(i2.getInputStream())); String i4 = ""; while (true) { String i5 = i3.readLine(); if (i5 == null) { i3.close(); break; } else { i4 += i5 + System.lineSeparator(); } } i2.disconnect(); File i5 = File.createTempFile("myTempFile", ".html"); FileOutputStream i6 = new FileOutputStream(i5); i6.write(i4.split("...")[0].getBytes("UTF-8")); i6.flush(); i6.close();
Here is the method that invokes the default browser assigned to the system:
Desktop.getDesktop().browse(new URI("file:///" + i5.getAbsolutePath().replace(File.separator, "/")));
Various HTML documents are downloaded from the Internet so often that in a few days there are more than a thousand. After all, you need to delete these files after use. I asked the question "how to do it ..", how to determine when the browser opened? That is, for example, Google Chrome can run for up to 5 seconds and then loads the necessary HTML document, the size of which is not limited. Therefore, it can load for a few minutes. How to make a listener that will tell me when the browser has loaded with my URI
.