How do I make sure that a file is not branchable across different projects in UCM ? 

It should always be picked from `/main/LATEST/` for all the parallel projects
['https://Stackoverflow.com/questions/38740587', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3119109/']
Did you read the JavaDocs on `isDirectory()` etc.? For `isDirectory()` it says: 

> 
> returns true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise
> 
> 
> 

So if the directory doesn't exist you get false and don't create one. Then you continue trying to write and create and write etc. until you get the StackOverFlowError.

To fix the stackoverflow you should check the return value of your create file, e.g.

```
boolean created = this.createFileMain(path);
if( created ) {
  this.writeInFile(path, content);
}

```

To fix your file/directory creation you need to check whether the file already exists and otherwise create it (optionally also creating the parent directories via `file.getParentFile().mkdirs()`).

The problem is that you should know whether you want to create a file or a directory, since you can't tell by the name alone whether the path is meant to be a directory or file name (unless you invent some markup like always ending a directory path with a separator or requiring files to always have an extension). If you want to write some content you need to create a file anyways, a directory would break your code again.
```
private boolean createFile(File file) {
    if(!file.exists()) {
        if(file.getParentFile().exists()) {
            // ...
        } else { // In this case, neither file nor its parent exist
            if(this.createDirectory(file)) {
                this.createFile(file); // HERE, you're calling the same method again
            } else {
                // ...;
            }
        }
    }
    return true;
}

```

I believe you want to replace the line marked `HERE` with `this.createFile(file.getParentFile());`. Here what happens is that your function recursively calls itself with the same arguments, so nothing ever happens, and your program gets stuck in a loop until it runs out of stack memory.