public class UrlUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
UrlUtil.UrlImpl |
Modifier and Type | Method and Description |
---|---|
static String |
encode(String data)
Encode.
|
static String |
generateUA()
generates a valid user-agent
something like: Mozilla/5.0 (Windows; Windows NT 6.1; Windows 7 6.1; U; amd64; de-DE; rv:57.0) Gecko/20100101 Firefox/57.0 but with correct OS and language values |
static String |
generateUA(String language)
generates a valid user-agent
something like: Mozilla/5.0 (Windows; Windows NT 6.1; Windows 7 6.1; U; amd64; de-DE; rv:57.0) Gecko/20100101 Firefox/57.0 but with correct OS and language values |
static String |
getBasename(String url)
gets the BaseName (w/o extension) of an URL (better than commons-io)
|
static String |
getBaseUrl(String url)
Returns the the entire Url Path except the filename, like doing a basedir on a filename.
|
static byte[] |
getByteArrayFromUrl(String urlAsString)
fetch the given url and return the content in a byte array
|
static byte[] |
getByteArrayFromUrl(String urlAsString,
UrlUtil.UrlImpl urlImpl)
fetch the given url and return the content in a byte array
|
static String |
getDomainUrl(String url)
Gets the domain url.
|
static String |
getExtension(String url)
gets the Extension of an URL (better than commons-io)
|
static String |
getFileExtension(String url)
Returns file extension from url.
|
static String |
getFilename(String url)
gets the FileName (with extension) of an URL (better than commons-io)
|
static String[] |
getFileNameArray(String url)
get the correct name/extension/filename of url (even with parameters! - commons-io CANNOT)
|
static Locale |
getLocaleFromLanguage(String language)
Gets a correct Locale (language + country) from given language.
|
static String |
getPathName(String url)
Gets the path name.
|
static String |
getStringFromUrl(String urlAsString)
fetch the given url and parse it into a
String |
static String |
getStringFromUrl(String urlAsString,
UrlUtil.UrlImpl urlImpl)
fetch the given url and parse it into a
String |
static URI |
getURIEncoded(String url)
Casts url string to URI, and does the correct encoding (rfc2396) of query string ONLY (eg "|" character).
|
static String |
joinUrlPath(String baseUrl,
String path)
Join url path.
|
static org.jsoup.nodes.Document |
parseDocumentFromUrl(String urlAsString)
fetch the given url and parse it into a
Document |
static org.jsoup.nodes.Document |
parseDocumentFromUrl(String urlAsString,
UrlUtil.UrlImpl urlImpl)
fetch the given url with the desired url type and parse it into a
Document |
public static final String UTF_8
public static URI getURIEncoded(String url) throws URISyntaxException
url
- the url as stringURISyntaxException
- if url could not be parsed / invalidpublic static String getFileExtension(String url) throws URISyntaxException
url
- the urlURISyntaxException
- if url is not validpublic static String getBasename(String url)
url
- the to get the base name frompublic static String getExtension(String url)
url
- the to get the extension frompublic static String getFilename(String url)
url
- the to get the file name frompublic static String getBaseUrl(String url)
url
- the urlpublic static String getDomainUrl(String url)
url
- the urlpublic static String joinUrlPath(String baseUrl, String path)
baseUrl
- the base urlpath
- the pathpublic static String getPathName(String url)
url
- the urlpublic static String[] getFileNameArray(String url)
url
- the urlpublic static String encode(String data)
data
- the datapublic static String generateUA()
public static String generateUA(String language)
language
- take the given language rather than the systems defaultpublic static Locale getLocaleFromLanguage(String language)
language
- as 2charpublic static org.jsoup.nodes.Document parseDocumentFromUrl(String urlAsString) throws IOException, InterruptedException
Document
urlAsString
- the url as stringDocument
IOException
- Indicates that an IOException
occurredInterruptedException
- Indicates that this thread as been interruptedpublic static org.jsoup.nodes.Document parseDocumentFromUrl(String urlAsString, UrlUtil.UrlImpl urlImpl) throws IOException, InterruptedException
Document
urlAsString
- the url as stringurlImpl
- the desired url typeDocument
IOException
- Indicates that an IOException
occurredInterruptedException
- Indicates that this thread as been interruptedpublic static String getStringFromUrl(String urlAsString) throws IOException, InterruptedException
String
urlAsString
- the url as stringString
IOException
- Indicates that an IOException
occurredInterruptedException
- Indicates that this thread as been interruptedpublic static String getStringFromUrl(String urlAsString, UrlUtil.UrlImpl urlImpl) throws IOException, InterruptedException
String
urlAsString
- the url as stringurlImpl
- the desired url typeString
IOException
- Indicates that an IOException
occurredInterruptedException
- Indicates that this thread as been interruptedpublic static byte[] getByteArrayFromUrl(String urlAsString) throws IOException, InterruptedException
urlAsString
- the url as stringIOException
- Indicates that an IOException
occurredInterruptedException
- Indicates that this thread as been interruptedpublic static byte[] getByteArrayFromUrl(String urlAsString, UrlUtil.UrlImpl urlImpl) throws IOException, InterruptedException
urlAsString
- the url as stringurlImpl
- the desired url typeIOException
- Indicates that an IOException
occurredInterruptedException
- Indicates that this thread as been interruptedCopyright © 2012–2019 tinyMediaManager. All rights reserved.