Java Utililty Methods Path Create nio

List of utility methods to do Path Create nio

Description

The list of methods to do Path Create nio are organized into topic(s).

Method

voidcreateFoldersIfNecessary(String workspacePath)
create Folders If Necessary
int lastIndexOf = workspacePath.lastIndexOf(File.separator);
if (lastIndexOf > 0) {
    String directory = workspacePath.substring(0, lastIndexOf);
    createFolder(directory);
URIcreateFullURI(String val, Path parent)
create Full URI
URI uri = URI.create(val.replace(" ", "%20"));
if (uri.getScheme() == null) {
    uri = new URI("file", val, null);
if (uri.isOpaque()) {
    uri = new URI("file", parent.resolve(val).toAbsolutePath().toString(), null);
return uri;
...
PathMatchercreateGlobMatcher(final Path path)
create Glob Matcher
checkNotNull(path, "path is null");
return FileSystems.getDefault().getPathMatcher("glob:" + path.toString());
voidcreateHeader(Path newFile)
create Header
try (BufferedWriter writer = Files.newBufferedWriter(newFile, Charset.defaultCharset(),
        new OpenOption[] { StandardOpenOption.APPEND })) {
    Date date = new Date();
    Calendar cal1 = Calendar.getInstance();
    cal1.setTimeInMillis(System.currentTimeMillis());
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-hh:mm:ss");
    String sDate = dateFormat.format(cal1.getTime());
    String developer = System.getProperty("user.name");
...
voidcreateHiddenFile(String filePath)
Creates a hidden file based on the directory and file name given.
String directory = filePath.substring(0, filePath.lastIndexOf(File.separator) + 1);
directory = checkDir(directory);
String fileName = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
new File(directory).mkdirs();
try {
    File file = null;
    switch (detectOS()) {
    case WINDOWS:
...
PathcreateIncrNonExistentFilename(final Path parent, final String prefix, final String suffix)
Create a non existent filename.
int i = 1;
Path result;
do {
    result = parent.resolve(prefix + i + suffix);
    ++i;
} while (Files.exists(result));
return result;
PathcreateJarFile(Path directory, String name, Optional manifest, Class[] classesToAdd, Map filesToAdd)
create Jar File
Path outputFile = directory.resolve(name);
OutputStream fileOutputStream = Files.newOutputStream(outputFile);
try (JarOutputStream outputStream = manifest.isPresent()
        ? new JarOutputStream(fileOutputStream, manifest.get())
        : new JarOutputStream(fileOutputStream, new Manifest())) {
    for (Class currentClass : classesToAdd) {
        addClass(outputStream, currentClass);
    for (String entryName : filesToAdd.keySet()) {
        Path file = filesToAdd.get(entryName);
        addPath(outputStream, file, entryName);
return outputFile;
voidcreateJSONFileIfNotExists(Path path)
create JSON File If Not Exists
if (!Files.exists(path)) {
    try {
        new File(path.toString()).createNewFile();
    } catch (IOException e) {
        throw new IllegalStateException("File " + path.toAbsolutePath() + " could not be created.");
} else
    System.out.println("File " + path.toString() + " already exists, so not recreated");
...
voidcreateLanguageStructure(final String lang, final Path docRootFolder)
create Language Structure
final Path langFolder = Files.createDirectory(docRootFolder).resolve(lang);
Files.createDirectory(langFolder.resolve("pages"));
Files.createDirectory(langFolder.resolve("faq"));
Files.createDirectory(langFolder.resolve("imgs"));
ListcreateList(Iterable dirs)
create List
List<Path> ret = new ArrayList<Path>(3);
for (Path path : dirs) {
    if (!Files.isReadable(path))
        continue;
    ret.add(path);
return ret;