I'd like to read contents of a textfile and display these in a JavaFX Scene Builder text area. I know how to do using a simple textfile but I must do it for an external textfile (means located on a server with HTTPS protocol).
I wrote the following snippet to check whether the file is available or not. That works but I must admit I'm stuck for the next step.. How could I parse and display the content of the file into the uiEtat
text area component ?
try {
HttpsURLConnection.setFollowRedirects(false);
HttpsURLConnection con =
(HttpsURLConnection) new URL("https://URL/file.txt").openConnection();
con.setRequestMethod("HEAD");
if (con.getResponseCode() == HttpsURLConnection.HTTP_OK){
uiEtat.setText(); // here we fill the label with contents of file.txt
}
else
uiEtat.setText("No content");
}
Any help would be greatly appreciated, thank you.