public void getFile(String path, File destination) throws IOException,
			HTTPException {
		path = urlEncodeFileNames(path);
		InputStream is = null;
		OutputStream os = null;
		destination.getParentFile().mkdirs();
		HttpURLConnection con = (HttpURLConnection) this.sc.getURL(
				"/file/" + path + "/").openConnection();
		con.setRequestMethod(ServerConnector.GET);
		con.setRequestProperty("Accept-Encoding", "gzip");
		con.setRequestProperty(ServerConnector.COOKIE, this.session);
		con.setDoInput(true);
		con.connect();
		try {
			switch (con.getResponseCode()) {
			case 200:
				if (destination.exists()) {
					destination.delete();
				}
				is = new GZIPInputStream(con.getInputStream());
				os = new FileOutputStream(destination);
				byte[] buf = new byte[4096];
				int len;
				try {
					while ((len = is.read(buf)) != -1) {
						os.write(buf, 0, len);
					}
				} finally {
					try {
						is.close();
					} catch (IOException ignore) {
					}
					try {
						os.close();
					} catch (IOException ignore) {
					}
				}
				break;
			case 401:
				throw new HTTPException(401, "get: " + ServerConnector.HTTP401);
			case 404:
				throw new HTTPException(404, "get: " + ServerConnector.HTTP404);
			case 405:
				throw new HTTPException(405, "get: " + ServerConnector.HTTP405);
			case 503:
				throw new HTTPException(503, "get: " + ServerConnector.HTTP503);
			default:
				throw new HTTPException(con.getResponseCode(), "get: "
						+ ServerConnector.HTTP_UNKNOWN);
			}
		} finally {
			con.disconnect();
		}
	}