Chat Program that Sends Bytes Instead of String
<p>I have a chat program I made a while ago for a class. I am trying to changes some parts of it and that includes sending bytes instead of strings. If anyone can guide to the correct direction on how to change this program to send bytes instead of strings,  please let me know.</p>

<pre><code>import java.awt. * ;
import java.awt.event. * ;
import java.net. * ;
import java.io. * ;
import javax.swing. * ;
import java.applet. * ; //for sounds
import java.net. * ; //for sounds
public class ServerChat extends JPanel implements Runnable, ActionListener {

    protected ServerSocket serverSocket;
    protected Socket socket;
    protected BufferedReader reader;
    protected BufferedWriter writer;
    protected JTextField text;
    protected JButton send, exit;
    protected List list;
    protected java.applet.AudioClip clip;
    protected Image bic = new ImageIcon("smoothy_blue.jpg").getImage();

    public ServerChat() {

        setLayout(null);

        send = new JButton("Send");
        send.addActionListener(this);
        exit = new JButton("Exit");
        exit.addActionListener(this);
        text = new JTextField();
        list = new List();
        list.setBounds(10, 10, 300, 350);
        add(list);
        send.setBounds(320, 340, 100, 20);
        add(send);
        exit.setBounds(320, 365, 100, 20);
        add(exit);
        text.setBounds(10, 365, 300, 20);
        add(text);
        connect();

    }

    public void playSound() {

        try {
            //create the clip that will played later
            clip = java.applet.Applet.newAudioClip(
              new java.net.URL("file:blip.wav"));
            clip.play();
        }
        catch (Exception xx) {
            xx.printStackTrace();
        }
    }

    public void connect() {
        try {
            // create the sever socket
            serverSocket = new ServerSocket(100);

            //accept the socket connection
            socket = serverSocket.accept();

            reader = new BufferedReader(
              new InputStreamReader(socket.getInputStream()));

            writer = new BufferedWriter(
              new OutputStreamWriter(socket.getOutputStream()));

            writer.write("Hello");
            writer.newLine();
            writer.flush();
            // start the thread
            Thread thread = new Thread(this);
            thread.start();


        } catch (Exception e) {
            e.getMessage();
        }

    }

    public void run() {
        try {
            socket.setSoTimeout(1);
        } catch (Exception e) {}
        while (true) {
            try {
                list.addItem(reader.readLine());
            } catch (Exception h) {
                h.getMessage();
            }
        }

    }

    public void sendMessage() {
        try {
            writer.write(text.getText());
            writer.newLine();
            writer.flush();
            text.setText("");
        } catch (Exception m) {
            m.getMessage();
        }
    }


    public void actionPerformed(ActionEvent event) {
        Object obj = event.getSource();

        if (obj == exit) {
            System.exit(0);
        }
        if (obj == send) {
            sendMessage();
            playSound();


        }
    }

    public void paintComponent(Graphics g) {

        super.paintComponent(g);
        g.drawImage(bic, 0, 0, null);

    }
}
</code></pre>
