package com.github.drexler;


import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Paths;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
import org.json.JSONObject;


public class VTLRunner {
    public static void main(String args[]){
        VelocityEngine ve = new VelocityEngine();
        StringWriter sw = new StringWriter();

        try {
        	
        	ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
        	ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
        	ve.init();
        	
        	
        	String templatePath = "testtemplate.vm";
            Template t = ve.getTemplate(templatePath);
            
            String jsonFile = new String(Files.readAllBytes(Paths.get("C:\\Repos\\personal\\velson\\Velson\\resources\\sample.json")));
            JSONObject jsonObj = new JSONObject(jsonFile);
            VelocityContext context = new VelocityContext();
            context.put("source", jsonObj);  
            t.merge(context, sw);

        }
        catch(Exception e) {
        	System.out.println(e);
        }

        System.out.println(sw);
    }
}

@@ -52,24 +52,75 @@
 ingWriter;%0D%0A
+import java.io.File;%0D%0Aimport java.io.IOException;%0D%0A
 import java.
@@ -132,24 +132,24 @@
 ile.Files;%0D%0A
-
 import java.
@@ -532,16 +532,57 @@
 rgs%5B%5D)%7B%0D
+%0A%0D%0A    %09VTLRunner vtl = new VTLRunner();%0D
 %0A       
@@ -907,27 +907,16 @@
      %09%0D%0A
-        %09%0D%0A
         
@@ -1062,113 +1062,68 @@
 e = 
-new String(Files.readAllBytes(Paths.get(%22C:%5C%5CRepos%5C%5Cpersonal%5C%5Cvelson%5C%5CVelson%5C%5Cresources%5C%5Csample.json%22)));
+vtl.getFileContents(%22sample.json%22);           %0D%0A            
 %0D%0A  
@@ -1409,24 +1409,24 @@
        %7D%0D%0A%0D%0A
-
         Syst
@@ -1453,11 +1453,311 @@
 %0A    %7D%0D%0A
+    %0D%0A    public String getFileContents(String fileName) throws IOException %7B%0D%0A    %09ClassLoader classLoader = getClass().getClassLoader();%0D%0A    %09File file = new File(classLoader.getResource(fileName).getFile());%0D%0A    %09return new String(Files.readAllBytes(Paths.get(file.getAbsolutePath())));%0D%0A    %7D%0D%0A
 %7D%0D%0A

remove hardcoded paths to resources