package ch.rasc.musicsearch.web;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import javax.servlet.http.HttpServletResponse;

import org.apache.lucene.document.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import ch.rasc.musicsearch.service.IndexService;

import com.google.common.io.ByteStreams;

@Controller
public class DownloadMusicController {

	@Autowired
	private Environment environement;

	@Autowired
	private IndexService indexService;

	@RequestMapping("/downloadMusic")
	public void download(@RequestParam(value = "docId", required = true) int docId, HttpServletResponse response)
			throws IOException {

		Document doc = indexService.getIndexSearcher().doc(docId);

		if (doc != null) {

			Path musicFile = Paths.get(environement.getProperty("musicDir"), doc.get("directory"), doc.get("fileName"));

			response.setContentLength((int) Files.size(musicFile));

			try (OutputStream out = response.getOutputStream()) {
				Files.copy(musicFile, out);
			}
		}

	}
}
@@ -46,83 +46,19 @@
 .io.
-BufferedInputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream
+IOException
 ;%0Aim
@@ -601,50 +601,8 @@
 e;%0A%0A
-import com.google.common.io.ByteStreams;%0A%0A
 @Con

Remove unused import statement