void joinFile() {
	
	FileOutputStream fos = null;
	byte [] buffer = new byte [chunkSize];

	try {
	    fos = new FileOutputStream(new File(System.getProperty("user.dir") + "/peer_" + pid + "/" + fileName));
	     
	} catch (FileNotFoundException e) {
	    // TODO Auto-generated catch block
	    e.printStackTrace();
	}
	 
	int index = 0;
	int bytesRead = 0;
	while (index < numberOfchunks) {
	    
	    FileInputStream fis = null;
	    File file = null;
	    try {
		file = new File(System.getProperty("user.dir") + "/peer_" + pid + "/chunk" + index++);
		fis = new FileInputStream(file);
		if (!fileExists) 
		    bytesRead = fis.read(buffer, 0, chunkSize);
	    } catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	    }
	    if (bytesRead == -1) {
		//log ("breakin cause -1 ", pid);
		break;
	    }
		    
	    try {
		if (!fileExists)
		    fos.write(buffer);
		fis.close();
		file.delete();
	    } catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	    }

	}
	
	if (!fileExists)
	    log ("Peer " +  pid + " has downloaded the complete file");
	
	try {
	    fos.close();
	} catch (IOException e) {
	    // TODO Auto-generated catch block
	    e.printStackTrace();
	}
    }