Writing a byte array to a file and looking at the file in java
<p>I want to write a byte[] data to a file and I found this code:</p>

<pre><code>public static void writeByte(String filename, byte[] data){

    BufferedOutputStream bos = null;

    try
    {
    //create an object of FileOutputStream
    FileOutputStream fos = new FileOutputStream(new File(filename));

    //create an object of BufferedOutputStream
    bos = new BufferedOutputStream(fos);


    /*
    * To write byte array to file use,
    * public void write(byte[] b) method of BufferedOutputStream
    * class.
    */
    System.out.println("Writing byte array to file");

    bos.write(data);

    System.out.println("File written");
    }
    catch(Exception fnfe)
    {
    System.out.println("exception");
    }
 }
</code></pre>

<p>This seems to work but I can't open the file to see the data...it says the "file is of an unknown type". Data was written because the file size is 25.5KB. My question is, how can I view the contents? Is there an extension that I have to use? Or do I need a special editor to open it? (Tried geany and gedit...)</p>
