public class Http extends Object
| 构造器和说明 |
|---|
Http() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
encodeHtml(String message)
This encodes the message into Html.
|
static List |
findAllHostAddresses(boolean includeLoopback) |
static InetAddress |
findRoutableHostAddress()
This method tries to find a suitable InetAddress that is routable.
|
static String |
formatTime(long time)
This formats the given time as a HTTP formatted string.
|
static String |
getCurrentTime()
This creates the current time as a string conforming to a HTTP date following the format
EEE, dd MMM yyyy HH:mm:ss z.
|
static String |
getStatusPhrase(int code)
Given a HTTP response code, this method will return the english phrase.
|
static boolean |
isSecure(String root,
File file) |
static String |
join(String path,
String relativePath)
Takes two paths a joins them together properly adding the '/' charater between them.
|
static long |
parseTime(String date)
This parses the given time as a HTTP formatted string.
|
static File |
translatePath(String root,
String url)
This translates a url into a path on the filesystem.
|
public static String getStatusPhrase(int code)
code - the HTTP response code to look up.public static String encodeHtml(String message)
message - the message to encode.public static String getCurrentTime()
public static String formatTime(long time)
time - the time to format into a string.public static long parseTime(String date) throws ParseException
date - The date represented as the format String EEE, dd MMM yyyy HH:mm:ss z.ParseException - throws this exeception when it cannot parse the date.public static String join(String path, String relativePath)
path - the first part of the path.relativePath - the second part to join to the first path.public static File translatePath(String root, String url) throws UnsupportedEncodingException
root - this is an absolute path to prepend onto the url.url - the url to resolve into the filesystem.UnsupportedEncodingExceptionpublic static boolean isSecure(String root, File file) throws IOException
IOExceptionpublic static InetAddress findRoutableHostAddress() throws UnknownHostException, SocketException
InetAddress.getLocalHost()
to find the local host. If that address it a site local address (192.168.*.*, 10.*.*.*, or 172.16.*.*) or the
loopback address (127.0.0.1), it enumerates all the NetworkInterfaces, and tries to find an address that is
not site local or loopback address. If it cannot it simply returns whatever InetAddress.getLocalHost().UnknownHostExceptionSocketExceptionpublic static List findAllHostAddresses(boolean includeLoopback) throws SocketException
SocketExceptionCopyright © 2025 onecode. All rights reserved.