|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectsimpleNetworking.ReaderWriter
public class ReaderWriter
A class for simple reading (via readLine and readLineIfReady) and writing (via writeLine), using a socket (i.e. through the network).
Constructor Summary | |
---|---|
ReaderWriter(Socket socket)
Constructs and stores a reader and writer for the given socket. |
Method Summary | |
---|---|
(package private) void |
close()
Closes all resources that this ReaderWriter uses: writer, reader, socket. |
String |
readLine()
Returns the next line available from the socket associated with this connection, stripping the terminating newline. |
String |
readLineIfReady()
Returns the next line available from the socket associated with this connection, stripping the terminating newline. |
void |
writeLine(String stringToWrite)
Sends the given String, appending a newline to it, to the socket associated with this connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReaderWriter(Socket socket) throws IOException
socket
- Socket from which to construct a reader and writer.
IOException
- if the reader and/or writer cannot be constructed.Method Detail |
---|
public String readLine() throws IOException
IOException
- if an IO error occurs while reading.public String readLineIfReady() throws IOException
IOException
- if an IO error occurs while reading.public void writeLine(String stringToWrite) throws IOException
stringToWrite
- String to send (with a newline appended)
to the socket associated with this connection.
IOException
- if an error occurs while writing.void close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |