Stay organized with collections
Save and categorize content based on your preferences.
URLUtil
public
final
class
URLUtil
extends Object
Summary
Inherited methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
Public constructors
URLUtil
public URLUtil ()
Public methods
composeSearchUrl
public static String composeSearchUrl (String inQuery,
String template,
String queryPlaceHolder)
Inserts the inQuery
in the template
after URL-encoding it. The encoded query
will replace the queryPlaceHolder
.
Parameters |
inQuery |
String |
template |
String |
queryPlaceHolder |
String |
decode
public static byte[] decode (byte[] url)
guessFileName
public static String guessFileName (String url,
String contentDisposition,
String mimeType)
Guesses canonical filename that a download would have, using the URL and contentDisposition.
File extension, if not defined, is added based on the mimetype.
The contentDisposition
argument will be treated differently depending on
targetSdkVersion.
- For targetSDK versions <
VANILLA_ICE_CREAM
it will be parsed based on RFC
2616.
- For targetSDK versions >=
VANILLA_ICE_CREAM
it will be parsed based on RFC
6266.
In practice, this means that from
VANILLA_ICE_CREAM
, this method will be able to
parse
filename*
directives in the
contentDisposition
string.
The function also changed in the following ways in VANILLA_ICE_CREAM
:
- If the suggested file type extension doesn't match the passed
mimeType
, the
method will append the appropriate extension instead of replacing the current
extension.
- If the suggested file name contains a path separator (
"/"
), the method will
replace this with the underscore character ("_"
) instead of splitting the
result and only using the last part.
Parameters |
url |
String : Url to the content |
contentDisposition |
String : Content-Disposition HTTP header or null |
mimeType |
String : Mime-type of the content or null |
Returns |
String |
suggested filename |
guessUrl
public static String guessUrl (String inUrl)
Cleans up (if possible) user-entered web addresses
isAboutUrl
public static boolean isAboutUrl (String url)
Returns |
boolean |
true if the url is an about: url. |
isAssetUrl
public static boolean isAssetUrl (String url)
Returns |
boolean |
true if the url is an asset file. |
isContentUrl
public static boolean isContentUrl (String url)
Returns |
boolean |
true if the url is a content: url. |
isCookielessProxyUrl
public static boolean isCookielessProxyUrl (String url)
This method was deprecated
in API level 15.
Cookieless proxy is no longer supported.
Returns |
boolean |
true if the url is a proxy url to allow cookieless network requests from a
file url. |
isDataUrl
public static boolean isDataUrl (String url)
Returns |
boolean |
true if the url is a data: url. |
isFileUrl
public static boolean isFileUrl (String url)
Returns |
boolean |
true if the url is a local file. |
isHttpUrl
public static boolean isHttpUrl (String url)
Returns |
boolean |
true if the url is an http: url. |
isHttpsUrl
public static boolean isHttpsUrl (String url)
Returns |
boolean |
true if the url is an https: url. |
isJavaScriptUrl
public static boolean isJavaScriptUrl (String url)
Returns |
boolean |
true if the url is a javascript: url. |
isNetworkUrl
public static boolean isNetworkUrl (String url)
Returns |
boolean |
true if the url is a network url. |
isValidUrl
public static boolean isValidUrl (String url)
Returns |
boolean |
true if the url is valid. |
stripAnchor
public static String stripAnchor (String url)
Strips the url of the anchor.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-04 UTC."],[],[]]