gt: 			outputFile = new File(jsonFileOutput);
context: package org.thebubbleindex.utilities.jsonhtml;
  
  import de.raida.cad.dex.CADExportContainer;
  import de.raida.cad.dex.cadexport.json.JSONExporterImplementation;
  import de.raida.cad.dex.cadimport.dxf.loader.DXFImporterImplementation;
  import de.raida.cad.dex.interfaces.CADExportInterface;
  import de.raida.cad.dex.interfaces.CADImportInterface;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.StringWriter;
  import java.nio.file.Files;
  import java.text.ParseException;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Properties;
  import java.util.Scanner;
  import java.util.concurrent.Callable;
  import java.util.concurrent.ExecutionException;
  import java.util.concurrent.ExecutorService;
  import java.util.concurrent.Executors;
  import java.util.concurrent.Future;
  import org.apache.velocity.VelocityContext;
  import org.apache.velocity.app.Velocity;
  import java.text.SimpleDateFormat;
  
  /**
   *
   * @author thebubbleindex
   */
  public final class CreateJSON3DFiles {
  
  	static String userDir = System.getProperty("user.dir");
  	static String filePathSymbol = File.separator;
  	static String inputDir = "/home/green/Desktop/XYZdxfFiles/";
  	static String outputDir = "/home/green/Desktop/HTMLContours/";
  	static String htmlTemplateFile = "/home/green/Desktop/template.html";
  	static String dailyDataFolder = "/media/green/Data/Dropbox/BubbleIndex/Version4/ProgramData/";
  	static double dailyDataConstant = 30.0;
  	private static String template;
  	private static int threadNumber = 4;
  	private String begDateString;
  	private String begDateStringStd;
  	private String endDateString;
  	private String endDateStringStd;
  	private int maxWindow;
  	private double maxValue;
  
  	static Properties properties = new Properties();
  
  	public CreateJSON3DFiles() {
  
  	}
  
  	/**
  	 * @param args
  	 *            the command line arguments
  	 * @throws java.io.IOException
  	 */
  	public static void main(final String[] args) throws IOException, InterruptedException, ExecutionException {
  		loadProperties(args);
  		System.out.println("userDir: " + userDir);
  		System.out.println("inputDir: " + inputDir);
  		System.out.println("outputDir: " + outputDir);
  		System.out.println("htmlTemplateFile: " + htmlTemplateFile);
  		System.out.println("dailyDataFolder: " + dailyDataFolder);
  
  		Velocity.init();
  
  		new CreateJSON3DFiles(true);
  	}
  
  	private int getMaxWinow(final File dataParentDir, final String indexName) {
  		final File[] files = dataParentDir.listFiles();
  		int maxWindow = 0;
  		for (final File file : files) {
  			if (file.getName().contains("days.csv")) {
  				final String cleanName = file.getName().replace(indexName, "").replace("days.csv", "");
  
  				try {
  					if (Integer.parseInt(cleanName) > maxWindow) {
  						maxWindow = Integer.parseInt(cleanName);
  					}
  				} catch (final Exception ex) {
  
  				}
  			}
  		}
  		return maxWindow;
  	}
  
  	private double getMaxValue(final String newFileName, final String indexName) {
  		final String xyzDataFileName = newFileName.replace("XYZdxfFiles", "XYZConversion").replace("values.json",
  				"maxValue.csv");
  		final File xyzFile = new File(xyzDataFileName);
  		double maxValue = 0.0;
  		if (xyzFile.exists()) {
  			try {
  				final String fileContents = new String(Files.readAllBytes(xyzFile.toPath()));
  				maxValue = Double.parseDouble(fileContents);
  			} catch (Exception ex) {
  			}
  		}
  		return maxValue;
  	}
  
  	public CreateJSON3DFiles(final boolean callablesBoolean)
  			throws IOException, InterruptedException, ExecutionException {
  
  		readTemplate();
  
  		final File fileFolder = new File(inputDir);
  
  		final File[] files = fileFolder.listFiles();
  
  		if (callablesBoolean) {
  
  			final ExecutorService executor = Executors.newFixedThreadPool(threadNumber);
  
  			final List<Callable<Boolean>> callables = new ArrayList<>();
  
  			for (final File file : files) {
  				if (file.isDirectory()) {
  					for (final File subFile : file.listFiles()) {
  						if (subFile.isDirectory()) {
  							for (final File subSubFile : subFile.listFiles()) {
  								callables.add(new MyCallable(subSubFile, new CreateJSON3DFiles()));
  							}
  						} else {
  							callables.add(new MyCallable(subFile, new CreateJSON3DFiles()));
  						}
  					}
  				} else {
  					callables.add(new MyCallable(file, new CreateJSON3DFiles()));
  				}
  			}
  
  			final List<Future<Boolean>> futures = executor.invokeAll(callables);
  
  			for (final Future<Boolean> future : futures) {
  				System.out.println("Results: " + (future.get() ? "Success" : "Failure"));
  			}
  
  			executor.shutdown();
  		} else {
  			loopThroughFilesConvertToJSON(files);
  		}
  	}
  
  	public void loopThroughFilesConvertToJSON(final File[] files) {
  		for (final File file : files) {
  			if (file.isDirectory()) {
  				System.out.println("Directory: " + file.getName());
  				loopThroughFilesConvertToJSON(file.listFiles());
  			} else {
  				try {
  					final String fileName = file.getName();
  					final String filePath = file.getAbsolutePath();
  
  					if (fileName.contains(".dxf")) {
  						System.out.println("Path: " + file.getAbsolutePath());
  						final CADImportInterface cadImportInterface = new DXFImporterImplementation();
  						cadImportInterface.importFile(filePath, null);
  
  						// Write the JSON file
  						final String editFileName = filePath.replace(".dxf", "");// remove
  																					// dxf
  																					// extension
  																					// from
  																					// file
  																					// name
  						final String newFilePath = editFileName + ".json";
  
  						final CADExportInterface cadExportInterface = new JSONExporterImplementation();
  						cadExportInterface.exportFile(newFilePath,
  								new CADExportContainer(cadImportInterface, newFilePath), null);
  
  						editJSONFile(newFilePath, file.getParentFile().getName());
  						int maxWindow = 0;
  						double maxValue = 0.0;
  						writeJSONDailyDataDir(newFilePath, file.getParentFile().getName());
  						writeHTMLFile(newFilePath, file.getParentFile().getName());
  					}
  				} catch (final Exception ex) {
  					System.out.println("Error at file: " + file.getName() + ex);
  				}
  			}
  		}
  	}
  
  	public static void editJSONFile(final String jsonFolderDir, final String folderName)
  			throws FileNotFoundException, IOException {
  		final String jsonFilePath = jsonFolderDir + filePathSymbol + "1.json";
  		final String jsonFileOutput = jsonFilePath.replace("XYZdxfFiles", "HTMLContours")
  				.replace("values.json" + filePathSymbol + "1.json", folderName + ".json");
  
  		FileInputStream inputStream = null;
  		FileOutputStream outputStream = null;
  		File inputFile = null;
  		File outputFile = null;
  
  		Scanner sc = null;
  		try {
  			inputFile = new File(jsonFilePath);
  