Java Code Examples for jodd.io.FileUtil#mkdirs()

The following examples show how to use jodd.io.FileUtil#mkdirs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SysToolkit.java    From DAFramework with MIT License 6 votes vote down vote up
public static void mklink(String target, String source) throws Exception {
	File fTarget = new File(polishFilePath(target));
	if (fTarget.exists() && fTarget.isDirectory()) {
		if (isSymbolicLink(target)) {
			exec("rd /q " + fTarget.getAbsolutePath(), ".", true, true);
		} else {
			FileUtil.deleteDir(fTarget);
		}
	}
	if (!fTarget.getParentFile().exists()) {
		FileUtil.mkdirs(fTarget.getParentFile());
	}
	File fSource = new File(polishFilePath(source));
	if (fSource.isDirectory()) {
		exec("mklink /d " + target + " " + source, ".", true, true);
	} else {
		exec("mklink /h " + target + " " + source, ".", true, true);
	}
}
 
Example 2
Source File: SysToolkit.java    From wES with MIT License 6 votes vote down vote up
public static void mklink(String target, String source) throws Exception {
	File fTarget = new File(polishFilePath(target));
	if (fTarget.exists() && fTarget.isDirectory()) {
		if (isSymbolicLink(target)) {
			exec("rd /q " + fTarget.getAbsolutePath(), ".", true, true);
		} else {
			FileUtil.deleteDir(fTarget);
		}
	}
	if (!fTarget.getParentFile().exists()) {
		FileUtil.mkdirs(fTarget.getParentFile());
	}
	File fSource = new File(polishFilePath(source));
	if (fSource.isDirectory()) {
		exec("mklink /d " + target + " " + source, ".", true, true);
	} else {
		exec("mklink /h " + target + " " + source, ".", true, true);
	}
}
 
Example 3
Source File: EsRestSpecGen.java    From wES with MIT License 6 votes vote down vote up
public void writeJavaFile() {
	try {
		String pkg2 = pkg + ".actions";
		StringBuilder javaCodes = new StringBuilder();
		javaCodes.append("package " + pkg2 + ";\n\n");

		javaCodes.append("import okhttp3.HttpUrl;\n" +
				"import org.datasays.wes.core.RequestInfo;\n" +
				"import org.datasays.wes.types.*;\n");
		javaCodes.append(codes.toString());
		javaCodes.append("}\n");
		String filePath = sourceDir + pkg2.replace('.', File.separatorChar) + File.separatorChar;
		FileUtil.mkdirs(filePath);
		FileUtil.writeString(filePath + clsName + ".java", javaCodes.toString(), "utf-8");
		codes = new StringBuilder();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example 4
Source File: EsDataHelper.java    From wES with MIT License 5 votes vote down vote up
/**
 * 备份es数据到backupDir目录
 *
 * @param index
 * @param type
 * @param backupDir
 */
@SuppressWarnings("unchecked")
public void backupData(String index, String type, String backupDir) {
	try {
		String path = path(backupDir, index, type);
		FileUtil.mkdirs(path);
		WPageIterator<Object> result = search(index, type, SearchQuery.MatchAll(), Object.class);
		while (result.hasNext()) {
			Object vo = result.next();
			WJsonUtils.writeJson(path + ((Map<Object, Object>) vo).get("id") + ".json", vo);
		}
	} catch (IOException e) {
		LOG.error(e.getMessage(), e);
	}
}
 
Example 5
Source File: EsRestSpecGen.java    From wES with MIT License 5 votes vote down vote up
public void writeEnumType(String type, List<String> options, String defaultValue, String description) {
	try {
		String pkg2 = pkg + ".types";
		StringBuilder javaCodes = new StringBuilder();
		javaCodes.append("package " + pkg2 + ";\n\n");

		javaCodes.append("//" + description + "\n");
		javaCodes.append("//default: " + defaultValue + "\n");
		javaCodes.append("public enum " + type + " {\n");
		String enumCodes = "";
		for (String option : options) {
			String enumName = option.toUpperCase();
			if (option.trim().length() <= 0) {
				enumName = "v";
			}
			enumCodes += "\t" + enumName + "(\"" + option + "\"),\n";
		}
		enumCodes = StringUtil.cutSuffix(enumCodes, ",\n");
		javaCodes.append(enumCodes + ";\n");

		javaCodes.append("\tprivate String name;\n");
		javaCodes.append("\t" + type + "(String name) {\n");
		javaCodes.append("\t\tthis.name = name;\n");
		javaCodes.append("\t}\n\n");
		javaCodes.append("\t@Override\n");
		javaCodes.append("\tpublic String toString() {\n");
		javaCodes.append("\treturn this.name;\n");
		javaCodes.append("\t}\n");
		javaCodes.append("}");
		String filePath = sourceDir + pkg2.replace('.', File.separatorChar) + File.separatorChar;
		FileUtil.mkdirs(filePath);
		FileUtil.writeString(filePath + type + ".java", javaCodes.toString(), "utf-8");
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example 6
Source File: EsRestSpecGen.java    From wES with MIT License 5 votes vote down vote up
public void writeEsHelper() {
	try {
		String pkg2 = pkg + ".client";
		StringBuilder javaCodes = new StringBuilder();
		javaCodes.append("package " + pkg2 + ";\n\n");

		javaCodes.append("import okhttp3.HttpUrl;\n");
		javaCodes.append("import okhttp3.OkHttpClient;\n");
		javaCodes.append("import org.datasays.wes.actions.*;\n");
		javaCodes.append("import org.datasays.wes.core.IConvert;\n");
		javaCodes.append("import org.datasays.wes.core.WHttpClient;\n\n");

		javaCodes.append("public class EsHelper extends WHttpClient {\n");
		javaCodes.append("\tprotected HttpUrl server;\n");
		javaCodes.append("\n");
		javaCodes.append("\tpublic EsHelper() {\n");
		javaCodes.append("\t\tsuper();\n");
		javaCodes.append("\t}\n\n");
		javaCodes.append("\tpublic void init(String server, OkHttpClient client, IConvert convert) {\n");
		javaCodes.append("\t\tif (server.trim().endsWith(\"/\")) {\n");
		javaCodes.append("\t\t\tserver = server.trim().substring(0, server.trim().length() - 1);\n");
		javaCodes.append("\t\t}\n");
		javaCodes.append("\t\tthis.server = HttpUrl.parse(server);\n");
		javaCodes.append("\t\tsuper.init(client, convert);\n");
		javaCodes.append("\t}\n\n");

		javaCodes.append(helperCodes.toString());

		javaCodes.append("}\n");

		String filePath = sourceDir + pkg2.replace('.', File.separatorChar) + File.separatorChar;
		FileUtil.mkdirs(filePath);
		FileUtil.writeString(filePath + "EsHelper.java", javaCodes.toString(), "utf-8");
	} catch (IOException e) {
		e.printStackTrace();
	}
}