All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.javaclub.cdl.client.util.LocalFileUtils Maven / Gradle / Ivy

There is a newer version: 2.3.9
Show newest version
package com.github.javaclub.cdl.client.util;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

public class LocalFileUtils {
	
	public static String rootPath = "/midware/logs";
	
	static {
		try {
			File defaultDir = new File(rootPath);
			if(defaultDir.exists() && defaultDir.canWrite()) {
				rootPath = rootPath + "/cdl-client";
				FileUtils.forceMkdir(new File(rootPath));
			} else {
				rootPath = "cdl-client";
				FileUtils.forceMkdir(new File("cdl-client"));
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	}
	
	public static String getLocalSaveDirPath() throws IOException{
		File dataDir = new File(rootPath + System.getProperty("file.separator") + "data");
		FileUtils.forceMkdir(dataDir);
		return rootPath + System.getProperty("file.separator") + "data";
	}
	
	public static String getLocalLogDirPath() throws IOException{
		File logDir = new File(rootPath + System.getProperty("file.separator") + "log");
		FileUtils.forceMkdir(logDir);
		return rootPath + System.getProperty("file.separator") + "log";
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy