Code example for OutputStreamWriter

Methods: closeflushwrite

0
    public static void main(String[] args) throws Exception {
 
        Socket s = new Socket("192.168.11.66", 3450);
 
        OutputStream os = s.getOutputStream();
        Writer out = new OutputStreamWriter(os);
        InputStream is = s.getInputStream();
        Reader reader = new InputStreamReader(is, "UTF-8");
        BufferedReader in = new BufferedReader(reader);
 
        String message = "Hola\n";
        out.write(message);
        out.flush();
        System.out.println("Message sent!");
 
        String result = in.readLine();
        System.out.println("Result: " + result);
 
        in.close();
        out.close();
        s.close();
 
    } 
 
} 
Connect your IDE to all the code out there  Get Codota for Java