executorService.execute(new Runnable() { public void run() { client = new Socket(IP_SERVER, PORT_SERVER); // Creating the server socket.
if (client != null) { // Receive video InputStream in = client.getInputStream(); OutputStream out[] = new OutputStream[1]; // Store on device out[0] = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Movies/chrono2.mp4"); byte buf[] = new byte[1024];
int n; while ((n = in.read(buf)) != -1) { out[0].write(buf, 0, n); //Adding last in the queue //Log.d("byte" , "" + out); }