int indexInModel = detailledModel.getIndexWebFile(this.webFile); detailledModel.fireTableRowsUpdated(indexInModel, indexInModel); } catch (IOException e) { System.err.println(e);
	public boolean download() throws IOException {		HttpURLConnection connection = null;		FileOutputStream fileOutputStream = null;		InputStream inputStream = null;		byte[] buffer = new byte[4096];		int nbBytes = 0;		String localPath = this.destDirectory + this.webFile.getURI().getPath();						/*		 * Open the connexion		 */		try {			connection = (HttpURLConnection) this.webFile.getURI().toURL().openConnection();			connection.connect();		} catch (IOException e) {						System.err.println(e);		}		//tests the response code		if (canBeDownloaded(connection)) {			try {				inputStream = connection.getInputStream();			} catch (IOException e2) {				System.err.println(e2);			}						/*			 * parameters from the file			 */			this.webFile.setContentType(connection.getContentType());			//we cannot know the realSize (certainly blocked by server)			if (connection.getContentLength() == -1) {				this.webFile.setRealSize(-2);			} else {				this.webFile.setRealSize(connection.getContentLength());				}			//			webFile.setBeginDate(new Date(connection.getDate()));									/*			 * Opening File for writing 			 */			File file = new File(localPath);			//creates the directory if it doesn't yet exist			if (!file.getParentFile().exists()) {				if (!file.getParentFile().mkdirs()) {					throw new IOException("Cannot create ancestor directories: '" + localPath + "'");					//TODO: voir si on quitte le programme ou pas				}			}						try {				fileOutputStream = new FileOutputStream(file);			} catch (FileNotFoundException e1) {				System.err.println(e1);			}									/*			 * Writing the data in the File			 */			try {				nbBytes = inputStream.read(buffer);			} catch (IOException e) {				System.err.println(e);			}			int downloadedSize = 0;			while (nbBytes > 0) {				try {					fileOutputStream.write(buffer, 0, nbBytes);					downloadedSize += nbBytes;					//progression in percent					if (this.webFile.getRealSize() == -2) {						//cannot kwnow the progression						this.webFile.setProgression(-2);					} else {						this.webFile.setProgression(downloadedSize * 100 / this.webFile.getRealSize());					}					//do a fire in the detailledModel					int indexInModel = detailledModel.getIndexWebFile(this.webFile);					detailledModel.fireTableRowsUpdated(indexInModel, indexInModel);				} catch (IOException e) {					System.err.println(e);				}				try {					nbBytes = inputStream.read(buffer);				} catch (IOException e) {					System.err.println(e);				}			}									/*			 * closing the streams			 */			try {				inputStream.close();				fileOutputStream.close();			} catch (IOException e) {				System.err.println(e);			}			return true;		}		return false;	}