public static String formatOutputName(String fileName, String prefix,
			boolean gzipped) {
		String rgx = "^.*\\.[tar\\.]?gz$";

		boolean hasGzip = Pattern.matches(rgx, fileName);

		fileName = (gzipped && !hasGzip) ? String.format("%s%s", fileName,
				GZIP_EXT) : fileName.replaceAll("\\.tar\\.gz$", GZIP_EXT);

		int splitIndex = fileName.lastIndexOf('/');
		String prefixFile = (splitIndex > 0) ? String.format("%s%s%s",
				fileName.substring(0, splitIndex + 1), prefix,
				fileName.substring(splitIndex + 1)) : String.format("%s%s",
				prefix, fileName);
		return prefixFile;
	}