@Component
public final class WebUtilities
extends java.lang.Object
| Constructor and Description |
|---|
WebUtilities(@NotNull ApplicationProperties injectedApplicationProperties) |
| Modifier and Type | Method and Description |
|---|---|
@NotNull java.lang.String |
createHasteBinFromFile(@NotNull java.io.File textFile)
Create a HasteBin post from a given text file.
|
boolean |
downloadAndReplaceFile(@NotNull java.io.File destinationFile,
@NotNull java.net.URL downloadURL)
Download the file from the specified URL to the specified destination, replacing the file if it
already exists.
|
boolean |
downloadAndReplaceFile(@NotNull java.lang.String fileDestination,
@NotNull java.net.URL downloadURL)
Download the file from the specified URL to the specified destination, replacing the file if it
already exists.
|
boolean |
downloadFile(@NotNull java.io.File destinationFile,
@NotNull java.net.URL downloadURL)
Download the file from the specified URL to the specified destination.
|
boolean |
downloadFile(@NotNull java.lang.String fileDestination,
@NotNull java.net.URL downloadURL)
Download the file from the specified URL to the specified destination.
|
@NotNull java.lang.String |
getResponseAsString(@NotNull java.net.URL url)
Get the reponse of a call to a URL as a string.
|
int |
getResponseCode(@NotNull java.net.URL url)
Get the response-code of a call to a URL as an integer.
|
boolean |
hasteBinPreChecks(@NotNull java.io.File fileToCheck)
Checks the filesize of the given file whether it is smaller or bigger than 10 MB.
|
boolean |
isReachable(@NotNull java.net.URL url)
Check the availability of the host of the given URL and whether the URL gives a status code of
200.
|
void |
openLinkInBrowser(@NotNull java.net.URI uri)
Open the given uri in a browser.
|
void |
openLinkInBrowser(@NotNull java.net.URL url)
Open the given url in a browser.
|
@Contract(pure=true)
public WebUtilities(@NotNull
@NotNull ApplicationProperties injectedApplicationProperties)
public boolean downloadAndReplaceFile(@NotNull
@NotNull java.io.File destinationFile,
@NotNull
@NotNull java.net.URL downloadURL)
destinationFile - The file to store the web-resource in. Examples:downloadURL - The URL to the file you want to download.public boolean downloadAndReplaceFile(@NotNull
@NotNull java.lang.String fileDestination,
@NotNull
@NotNull java.net.URL downloadURL)
fileDestination - The file to store the web-resource in. Examples:downloadURL - The URL to the file you want to download.public boolean downloadFile(@NotNull
@NotNull java.lang.String fileDestination,
@NotNull
@NotNull java.net.URL downloadURL)
fileDestination - The destination where the file should be stored. Must include the
filename as well. Examples:downloadURL - The URL to the file you want to download.public boolean downloadFile(@NotNull
@NotNull java.io.File destinationFile,
@NotNull
@NotNull java.net.URL downloadURL)
destinationFile - File. The file to store the web-resource in. Examples:downloadURL - URL. The URL to the file you want to download.public void openLinkInBrowser(@NotNull
@NotNull java.net.URL url)
url - The URI to the website you want to open.public void openLinkInBrowser(@NotNull
@NotNull java.net.URI uri)
uri - The URI to the website you want to open.public boolean hasteBinPreChecks(@NotNull
@NotNull java.io.File fileToCheck)
fileToCheck - The file or directory to check.@NotNull
public @NotNull java.lang.String createHasteBinFromFile(@NotNull
@NotNull java.io.File textFile)
textFile - The file which will be read into a String of which then to create a HasteBin
post of.@NotNull
public @NotNull java.lang.String getResponseAsString(@NotNull
@NotNull java.net.URL url)
throws java.io.IOException
url - The URL you want to get the response fromjava.io.IOException - if the URL could not be called or a communication error occurred.public int getResponseCode(@NotNull
@NotNull java.net.URL url)
throws java.io.IOException
url - The URL you want to get the response fromjava.io.IOException - if the URL could not be called or a communication error occurred.public boolean isReachable(@NotNull
@NotNull java.net.URL url)
true.url - The URL of which to check for host-availability.true if, and only if, the host is available and the URL returns the status code
200..