@SuppressWarnings("resource")
	public void setMapFromFile(String fileName) throws FileNotFoundException, MapFileException {
		
		Scanner scanner = new Scanner(new File("files/"+fileName));
		
		// width
		if (scanner.hasNextInt()) {
			int width = scanner.nextInt();
			if (width >= 0) {
				this.widthMap = width;
			}
			else {
				throw new MapFileException("the given width is negative !");
			}
		}
		else {
			throw new MapFileException("the file doesn't contain any integer !");
		}
		
		//height
		if (scanner.hasNextInt()) {
			int height = scanner.nextInt();
			if (height >= 0) {
				this.heightMap = height;
			}
			else {
				throw new MapFileException("the given height is negative !");
			}
		}
		else {
			throw new MapFileException("the file doesn't contain enough integers !");
		}
		
		// all int from map
		this.map = new int[this.widthMap][this.heightMap];
		
		for(int j=0; j<this.heightMap; ++j) {
			for(int i=0; i<this.widthMap; ++i) {
			
				if (scanner.hasNextInt()) {
					this.map[i][j] = scanner.nextInt();
				}
				else {
					throw new MapFileException("the file doesn't contain enough integers !");
				}
			}
		}
	}