Java Utils

Given a path, create the missing sub directory
private void mkDirs(String path) {
	List<String> dirs = new ArrayList<String>();
	if (path != null && path.length() > 0) {
		String[] parts = path.split("\\\\");// split by two '\'
		for (String part : parts) {
			dirs.add(part);
		}
		
		StringBuilder pathConcat = new StringBuilder("\\\\");
		for (String s : dirs) {
			if (s != null && s.length() > 0) {
				pathConcat.append(s).append("\\");
				File subdir = new File(pathConcat.toString());
				if (!subdir.exists() && !s.endsWith(".sql") ) {
					subdir.mkdir();
				}
			}
		}
	}
}

你可能感兴趣的:(java,utils,帮助类)