android add filename to bytestream
<p>im trying to send a file in android through sockets. i want to add the filename with the bytestream and then send it to the server. how do i do that? and then how do i seperate the filename on the receiving side?
this is the code to send file :</p>

<pre><code> Log.i("SocketOP", "sendFILE-1");
            File  f = new File(path);
            String filename=path.substring(path.lastIndexOf("/")+1);
            System.out.println("filename:"+filename); 
            fin.filename = "~"+filename;
            BufferedOutputStream out = new BufferedOutputStream( socket.getOutputStream() );

            FileInputStream fileIn = new FileInputStream(f);
            Log.i("SocketOP", "sendFILE-2");
            byte [] buffer  = new byte [(int)f.length()];
            System.out.println("SO sendFile f.length();" + f.length());
            int bytesRead =0;
            while ((bytesRead = fileIn.read(buffer)) &gt; 0) {
                out.write(buffer, 0, buffer.length);
                System.out.println("SO sendFile" + bytesRead +filename);
            }
            out.flush();
            out.close();
            fileIn.close();
            Log.i("SocketOP", "sendFILE-3");
</code></pre>
