@Mario248
Do not escape the entire path, just escape the name of file here i.e. tco[a].jpg
JcrUtil.createPath("parentCategoty/" + JcrUtil.escapeIllegalJcrChars("tco[a].jpg"),JcrConstants.NT_UNSTRUCTURED, session);
If you want to validate each node name in path then
String[] nodesArray = path.split("/");
String escapedPath = "";
for (String nodeName : nodesArray) {
if (nodeName.isEmpty())
continue;
escapedPath += "/" + (JcrUtil.isValidName(nodeName)? nodeName : JcrUtil.escapeIllegalJcrChars(nodeName));
}
JcrUtil.createPath(escapedPath, JcrConstants.NT_UNSTRUCTURED, jcrSession);