Java - convert character to byte
<p>All I want to do is read characters from a notepad and convert it to bytes and save it another file.</p>

<p>"a.txt" has the simple text in notepad "Hello World!"</p>

<p>However, in "b.txt", I still see the human readable characters instead of the byte values. I also noticed that when I do a <code>System.out.print(ba)</code>, it prints the bytes.</p>

<p>Can anyone tell me why Java does not write the byte values to "b.txt"?</p>

<pre><code>import java.io.*;

class a {
    static int f;
    static String s;

    public static void main(String args[]) 
    throws IOException {
        BufferedReader  br = new BufferedReader(new FileReader ("a.txt"));
        BufferedOutputStream w = new BufferedOutputStream(new FileOutputStream("b.txt"));

        byte ba[] = new byte[1024];

        while((s=br.readLine())!=null) {
            ba = s.getBytes();
            System.out.print(ba);
            w.write(ba);
        }
    w.flush();
    w.close();
    br.close();
    }
}
</code></pre>
