@Component
public final class WebUtilities
extends java.lang.Object
| Constructor and Description |
|---|
WebUtilities(ApplicationProperties injectedApplicationProperties) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
createHasteBinFromFile(java.io.File textFile)
Create a HasteBin post from a given text file.
|
boolean |
downloadAndReplaceFile(java.io.File destinationFile,
java.net.URL downloadURL)
Download the file from the specified URL to the specified destination, replacing the file if it
already exists.
|
boolean |
downloadAndReplaceFile(java.lang.String fileDestination,
java.net.URL downloadURL)
Download the file from the specified URL to the specified destination, replacing the file if it
already exists.
|
boolean |
downloadFile(java.io.File destinationFile,
java.net.URL downloadURL)
Download the file from the specified URL to the specified destination.
|
boolean |
downloadFile(java.lang.String fileDestination,
java.net.URL downloadURL)
Download the file from the specified URL to the specified destination.
|
java.lang.String |
getResponseAsString(java.net.URL url)
Get the reponse of a call to a URL as a string.
|
int |
getResponseCode(java.net.URL url)
Get the response-code of a call to a URL as an integer.
|
boolean |
hasteBinPreChecks(java.io.File fileToCheck)
Checks the filesize of the given file whether it is smaller or bigger than 10 MB.
|
void |
openLinkInBrowser(java.net.URI uri)
Open the given uri in a browser.
|
void |
openLinkInBrowser(java.net.URL url)
Open the given url in a browser.
|
public WebUtilities(ApplicationProperties injectedApplicationProperties)
public boolean downloadAndReplaceFile(java.io.File destinationFile,
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(java.lang.String fileDestination,
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(java.io.File destinationFile,
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 boolean downloadFile(java.lang.String fileDestination,
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 void openLinkInBrowser(java.net.URL url)
url - The URI to the website you want to open.public void openLinkInBrowser(java.net.URI uri)
uri - The URI to the website you want to open.public boolean hasteBinPreChecks(java.io.File fileToCheck)
fileToCheck - The file or directory to check.public java.lang.String createHasteBinFromFile(java.io.File textFile)
textFile - The file which will be read into a String of which then to create a HasteBin
post of.public java.lang.String getResponseAsString(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(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.