GroupDocsGists
10/24/2017 - 1:15 PM

Examples-GroupDocs.Assembly.Examples.Java-src-main-java-com-groupdocs-assembly-examples-CommonUtilities-CommonUtilities.java

// For complete examples and data files, please go to https://github.com/groupdocs-assembly/GroupDocs.Assembly-for-Java
public class CommonUtilities {
	public static final String licensePath = "D:/GroupDocs.Assembly Product Family.lic";
	public static final Path storagePath = getProjectBaseDir().resolve("Data/Storage/");
	public static final Path outputPath = getProjectBaseDir().resolve("Data/Output/");
	public static final Path image = getProjectBaseDir().resolve("Data/Images/");
	public static final Path outerDoc = getProjectBaseDir().resolve("Data/OuterDocument/");
	public static final Path wordDataFile = getProjectBaseDir().resolve("Data/Data Sources/Word DataSource/");
	public static final Path excelDataFile = getProjectBaseDir().resolve("Data/Data Sources/Excel DataSource/");
	public static final Path presentationDataFile = getProjectBaseDir().resolve("Data/Data Sources/Presentation DataSource/");

	public static void applyLicense() {
		try {
			// Setup license
			License lic = new License();
			lic.setLicense(licensePath);
		} catch (Exception exp) {
			System.out.println("Exception: " + exp.getMessage());
			exp.printStackTrace();
		}
	}

	public static Path getProjectBaseDir() {
		Properties props = new Properties();
		try {
			InputStream i = CommonUtilities.class.getResourceAsStream("/project.properties");
			props.load(i);
		} catch (IOException x) {
			throw new RuntimeException(x);
		}
		return FileSystems.getDefault().getPath(props.getProperty("project.basedir"));
	}

	public static String getTestDataPath(String fileName) throws Exception {
		return storagePath + fileName;
	}

	public static String getTestOutPath(String fileName) throws Exception {
		return outputPath + fileName;
	}

}