Package org.polyfrost.oneconfig.utils.v1
Class NetworkUtils
java.lang.Object
org.polyfrost.oneconfig.utils.v1.NetworkUtils
Utility class for accessing the internet.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbrowseLink(String uri) Launches a URL in the default browser.static booleandownloadFile(String url, Path path) Downloads a file from a URL.static booleandownloadFile(String url, Path path, String userAgent, int timeout, boolean useCaches) Downloads a path from a URL.static StringGets the contents of a URL as a String.static StringGets the contents of a URL as a String.static InputStreamsetupConnection(String url) static InputStreamsetupConnection(String url, String userAgent, int timeout, boolean useCaches)
-
Field Details
-
DEF_AGENT
- See Also:
-
-
Method Details
-
getString
Gets the contents of a URL as a String.- Parameters:
url- The URL to read.userAgent- The user agent to use.timeout- The timeout in milliseconds.useCaches- Whether to use caches.- Returns:
- The contents of the URL.
-
getString
Gets the contents of a URL as a String.- Parameters:
url- The URL to read.- Returns:
- The contents of the URL.
- See Also:
-
downloadFile
public static boolean downloadFile(String url, Path path, String userAgent, int timeout, boolean useCaches) Downloads a path from a URL.- Parameters:
url- The URL to download from.path- The path to download to.userAgent- The user agent to use.timeout- The timeout in milliseconds.useCaches- Whether to use caches.- Returns:
- Whether the download was successful.
-
downloadFile
Downloads a file from a URL.- Parameters:
url- The URL to download from.path- The file to download to.- Returns:
- Whether the download was successful.
- See Also:
-
browseLink
Launches a URL in the default browser.- Parameters:
uri- The URI to launch- See Also:
-
setupConnection
- Throws:
IOException
-
setupConnection
public static InputStream setupConnection(String url, String userAgent, int timeout, boolean useCaches) throws IOException - Throws:
IOException
-