Question: I am trying to divide my string in 2 lines if string is greater than 15 characters, so i am finding a space after 15 char and putting /n to string so that when var gets printed it should get printed in 2 lines. 
following is my JavaScript code. its not working, please if anyone can help.
Thankyou 

```
  var name = row.product_name;
                    var val = 15;
                    var output;
                    var flag = false;
                    console.log(name[0]);
                    for(i=0; i<row.product_name.length; i++)
                    {      
                        if(i > val)
                        {
                            if(name[i] == ' ')
                            {
                                name[i] = "/n";
                                flag = true;
                            }
                        }
                        if(flag)
                        {
                            val = val + 15;
                            flag = false;
                        }
                    }

```

Answer: 
> 
> My current plan is to split the string `repo/dir/file.java` on the forward slash, and create directories until the last element of the split result
> 
> 
> 

Rather than splitting your string manually, you could try using [`File.mkdirs()`](https://docs.oracle.com/javase/8/docs/api/java/io/File.html#mkdirs--):

```
File newDirectoryStructureParent = new File('some/path/to/parent/dir')

def s = 'repo/dir/file.java'
def newContainer = new File(s, newDirectoryStructureParent).getParent()
newContainer.mkdirs()

```
everyone
In this part of my code you can just work around Path not File!

At the first you can define Path and second need check that path exist or not, if not mkdirs can make it ;)

Its help when you unknown about that path exist or not /

```
File fullPath = new File('/tmp/Test1')
if (!fullPath.exists())
    fullPath.mkdirs()

```