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 browserstatic booleandownloadFile(String url, Path path) Downloads a file from a URLstatic booleandownloadFile(String url, Path path, String userAgent, int timeout, boolean useCaches) Downloads a path from a URLstatic @Nullable StringGets the contents of a URL as a Stringstatic @Nullable StringGets the contents of a URL as a Stringstatic InputStreamsetupConnection(String url) static InputStreamsetupConnection(String url, String userAgent, int timeout, boolean useCaches)
-
Field Details
-
DEF_AGENT
- See Also:
-
-
Method Details
-
getString
@Nullable public static @Nullable String getString(String url, String userAgent, int timeout, boolean useCaches) Gets the contents of a URL as a String- Parameters:
url- The URL to readuserAgent- The user agent to usetimeout- The timeout in millisecondsuseCaches- Whether to use caches- Returns:
- The contents of the URL or
nullif the request failed
-
getString
Gets the contents of a URL as a String- Parameters:
url- The URL to read- Returns:
- The contents of the URL or
nullif the request failed - 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 frompath- The path to download touserAgent- The user agent to usetimeout- The timeout in millisecondsuseCaches- Whether to use caches- Returns:
- Whether the download was successful
-
downloadFile
Downloads a file from a URL- Parameters:
url- The URL to download frompath- 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
-