How to get the byte array from the file path in the array from? : <p>I need to get the byte array from file path to upload the image. But the byte array in the form of array.How do i get the byte array. I have followed the following steps but could not found the solutions.</p>

<p>I have tried the following code but does not work.</p>

<pre><code>byte []buffer=new byte[1024];
    ByteArrayOutputStream os=new ByteArrayOutputStream();
    FileInputStream fis=new FileInputStream(f);
    int read;
    while ((read=fis.read(buffer))!=-1){
        os.write(buffer,0,read);
    }
    fis.close();
    os.close();
</code></pre>

<p>It return the byte array object but i need the array. When i used Array.toString(bytearray) it return in the string form but i need the array form. Please help me how can i do this.</p>
