Package com.alipay.sofa.common.utils
Class ResourceUtil
java.lang.Object
com.alipay.sofa.common.utils.ResourceUtil
- Since:
- 1.0.17
- Author:
- qilong.zql, Juergen Hoeller
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
URL protocol for a file in the file system: "file" -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic File
Resolve the given resource URL to ajava.io.File
, i.e.static File
Resolve the given resource URL to ajava.io.File
, i.e.static URI
Create a URI instance for the given location String, replacing spaces with "%20" URI encoding first.static URI
Create a URI instance for the given URL, replacing spaces with "%20" URI encoding first.
-
Field Details
-
URL_PROTOCOL_FILE
URL protocol for a file in the file system: "file"- See Also:
-
-
Constructor Details
-
ResourceUtil
public ResourceUtil()
-
-
Method Details
-
getFile
Resolve the given resource URL to ajava.io.File
, i.e. to a file in the file system.- Parameters:
resourceUrl
- the resource URL to resolve- Returns:
- a corresponding File object
- Throws:
FileNotFoundException
- if the URL cannot be resolved to a file in the file system
-
getFile
Resolve the given resource URL to ajava.io.File
, i.e. to a file in the file system.- Parameters:
resourceUrl
- the resource URL to resolvedescription
- a description of the original resource that the URL was created for (for example, a class path location)- Returns:
- a corresponding File object
- Throws:
FileNotFoundException
- if the URL cannot be resolved to a file in the file system
-
toURI
Create a URI instance for the given URL, replacing spaces with "%20" URI encoding first.- Parameters:
url
- the URL to convert into a URI instance- Returns:
- the URI instance
- Throws:
URISyntaxException
- if the URL wasn't a valid URI- See Also:
-
toURI
Create a URI instance for the given location String, replacing spaces with "%20" URI encoding first.- Parameters:
location
- the location String to convert into a URI instance- Returns:
- the URI instance
- Throws:
URISyntaxException
- if the location wasn't a valid URI
-