Code example for OutputStreamWriter

0
    private static boolean writeValue(Socket client, String value) {
        boolean result;
        BufferedWriter out = null;
        try { 
            OutputStream clientStream = client.getOutputStream();
            out = new BufferedWriter(new OutputStreamWriter(clientStream), 8 * 1024);
            out.write(value);
            out.write("\n");
            out.flush();
            result = true;
        } catch (Exception e) {
            result = false;
        } finally { 
            if (out != null) {
                try { 
                    out.close();
                } catch (IOException e) {
                    result = false;
                } 
            } 
        }