In a piece of some Gradle code I want to get a current folder name without splitting the path. But all attempts that I tried:
Paths.get(".").getFileName()
new File(".").getName()
new File(".").name
, return a dot "." instead of the name. Is there some function that gives the name, not another string by which the folder could be addressed?
What is interesting, if I use:
String currentDirPath = new File(".").absolutePath
println currentDirPath
currentDirPath = currentDirPath.substring(0,currentDirPath.lastIndexOf("\\"))
println currentDirPath
String currentDir = currentDirPath.substring(currentDirPath.lastIndexOf("\\")+1)
, it is seen, that the path string looks as:
C:\Users\543829657\workspace\dev.appl.ib.cbl\application\.
So, it is simply incorrect to take the last substring after '\'. But all those three functions take not the name of the name of the really actual folder, but the last "."!