Write Text to a To Socket

Introduction

Writing to a metwork socket is very similar to writing to a file as you can see in the example below. It now only gets the OutputStream from the socket.

try {
    BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
    wr.write("aString");
    wr.flush();
} catch (IOException e) {
}
Related

Reading from a URL 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.