public static void writeText(File target, String text) {
    target.getParentFile().mkdirs();
    GFileUtils.writeFile(text, target);
  }
@Test
  public void writesTextOnNonExistentFile() throws IOException
  {
    Path tempDirectory = Files.createTempDirectory(getClass().getSimpleName());
    File f = tempDirectory.resolve("foo/bar/baz.txt").toFile();

    f.delete();
    f.getParentFile().delete();

    assertFalse(f.exists());
    assertFalse(f.getParentFile().exists());

    //when
    IOUtil.writeText(f, "foo");

    //then
    assertEquals(GFileUtils.readFile(f), "foo");

    deleteDirectory(tempDirectory);
  }