public class URLManager extends Object
Modifier and Type | Field and Description |
---|---|
static Class<URLConnection> |
CONNECTION
default connection.
|
static Class<HttpURLConnection> |
HTTP_CONNECTION
http connection.
|
static Class<HttpsURLConnection> |
HTTPS_CONNECTION
https connection.
|
Modifier and Type | Method and Description |
---|---|
<T extends URLConnection> |
getConnection(Class<T> tClass)
get connection
|
String |
getContent()
get all content inside url
|
Map<String,List<String>> |
getHeader()
get all header fields
|
InputStream |
getInputStream() |
Protocol |
getProtocol() |
InputStream |
getSpecifyInputFromConnection(RequestMethod method,
String input,
RequestProp... props) |
URL |
getUrl() |
static URLManager |
getUrl(Protocol protocol,
String link)
get url utility
|
static URLManager |
getUrl(String link)
get url utility
|
static URLManager |
getUrl(URL url)
get url utility
|
String |
getURLFilename()
get file name
Example: https://xyz.com/re/as/fe/test.txt the return will be "test.txt" |
long |
getURLSize()
get content length/size
|
void |
printHeader()
print all header to (DEBUG TOOL)
|
String |
toString() |
public static final Class<HttpURLConnection> HTTP_CONNECTION
public static final Class<HttpsURLConnection> HTTPS_CONNECTION
public static final Class<URLConnection> CONNECTION
public static URLManager getUrl(URL url)
url
- the url linkURLManager
public static URLManager getUrl(String link)
link
- the linkURLManager
public static URLManager getUrl(Protocol protocol, String link)
protocol
- web protocollink
- web link (without http:// or https://)URLManager
public URL getUrl()
public Protocol getProtocol()
public <T extends URLConnection> T getConnection(Class<T> tClass)
T
- the class to cast (beware if it cause ClassCastException
this method will return null)tClass
- output classor {@code null}
public InputStream getInputStream()
null
public String getContent()
public long getURLSize()
-1
if have some errorpublic String getURLFilename()
public InputStream getSpecifyInputFromConnection(RequestMethod method, String input, RequestProp... props)
method
- request method RequestMethod
input
- can be null
props
- request property e.g. headers(Headers
)null
if cause some errorpublic Map<String,List<String>> getHeader()
Map
value, or null
public void printHeader()
Copyright © 2017. All rights reserved.