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 .

  • Not completely understand your yuzkeys. Why can not I clean the files on a schedule? - Nofate
  • How to set the schedule if I do not know when the browser completely read the file? This is the problem. - nick
  • Just clean the folder once a day. - Nofate
  • The computer works without a break around the clock. I do not know when the browser downloads files, so the server is arranged. - nick
  • Once again: it will be easier for you to advise something, if you describe a common task. Is the process scheduled or continuous? The computer on which it all happens conditionally "your" or "enemy"? Does the user look into the browser or are you running some scripts there? The browser is always specific or it can be any: So far I see two options: clean the entire folder at some point (night, start the application, whatever, depending on the usage profile of your software) or write your own plugin in the browser that will notify your server what you want - Nofate

0