|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.baka.ambient.commons.IOUtils
public final class IOUtils
Contains IO and HTTP utility methods.
| Nested Class Summary | |
|---|---|
static class |
IOUtils.HttpRequest
The http request |
| Method Summary | |
|---|---|
static void |
cat(java.io.Reader r)
Cat given reader to log. |
static void |
copy(java.io.InputStream in,
java.io.OutputStream out,
int bufferSize)
Copies input stream to the output stream. |
static java.lang.String |
encodeURL(java.lang.String url)
Encodes given URL as per URLEncoder.encode(String, String). |
static java.lang.String |
formatIP(int address)
Formats IP address contained in an integer and returns it as a string. |
static java.lang.String |
getExt(java.lang.String name)
Returns the extension of the file, starting with dot character. |
static IOUtils.HttpRequest |
parseRequest(java.lang.String request)
Parses given HTTP request. |
static void |
parseXML(java.io.InputStream in,
org.xml.sax.ContentHandler handler)
Parses XML readable from given stream. |
static java.lang.String |
readLine(java.io.InputStream in)
Reads a line from given stream. |
static void |
readRequest(java.io.InputStream in)
Reads the request until an empty string is encountered. |
static java.lang.String |
removeTrailingSlash(java.lang.String name)
Removes trailing slash from given file name. |
static java.lang.String |
stripExt(java.lang.String name)
Strips extension from given name. |
static void |
writeHttpResponse(byte httpVer,
int httpCode,
boolean keepAlive,
long size,
java.lang.String resultMime,
java.io.OutputStream out)
Writes HTTP response. |
static void |
writeLine(java.io.OutputStream out)
Writes an empty line to given stream. |
static void |
writeLine(java.lang.String string,
java.io.OutputStream out)
Writes a line to given stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String encodeURL(java.lang.String url)
URLEncoder.encode(String, String). Uses
UTF-8 encoding. Spaces are correctly represented as %20.
url - the URL to encode
public static void parseXML(java.io.InputStream in,
org.xml.sax.ContentHandler handler)
throws java.io.IOException,
org.xml.sax.SAXException
in - the stream, always closed.handler - handles XML events.
org.xml.sax.SAXException - if parsing fails
java.io.IOException - if i/o error occurs
public static java.lang.String readLine(java.io.InputStream in)
throws java.io.IOException
in - the stream to read from. This should be an
BufferedInputStream implementation for performance
reasons.
null on end-of-stream.
java.io.IOException - if i/o error occurs.
public static void writeLine(java.lang.String string,
java.io.OutputStream out)
throws java.io.IOException
string - the string to write. It must consist of ASCII characters only.out - the stream to write to.
java.io.IOException - if i/o error occurs.
public static void writeLine(java.io.OutputStream out)
throws java.io.IOException
out - the stream to write to.
java.io.IOException - if i/o error occurs.public static java.lang.String stripExt(java.lang.String name)
name - the name to strip extension from
public static void copy(java.io.InputStream in,
java.io.OutputStream out,
int bufferSize)
throws java.io.IOException
in - the input stream. Always closed.out - the output stream. Always closed.bufferSize - the buffer size in bytes
java.io.IOException - thrown when i/o error occurs or when interrupted.public static java.lang.String removeTrailingSlash(java.lang.String name)
name - the file name.
public static void readRequest(java.io.InputStream in)
throws java.io.IOException
in - the stream to read from.
java.io.IOException - if i/o error occurs.
public static IOUtils.HttpRequest parseRequest(java.lang.String request)
throws ServerHttpException
request - the request
null if the request is malformed.
ServerHttpException - on HTTP error.
public static void writeHttpResponse(byte httpVer,
int httpCode,
boolean keepAlive,
long size,
java.lang.String resultMime,
java.io.OutputStream out)
throws java.io.IOException
httpVer - the HTTP version, 0 or 1.httpCode - the HTTP code.keepAlive - if true then "keep-alive" is written. If
false then "close" is written.size - the size of the content. -1 if not known.resultMime - response MIME type.out - write the response here.
java.io.IOException - if i/o error occurspublic static void cat(java.io.Reader r)
r - the reader to cat.public static java.lang.String formatIP(int address)
address - the IP to decode
public static java.lang.String getExt(java.lang.String name)
name - the file name to get the extension from.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||