public static String safeAppendDirectory( String dir, String file ) {
    boolean dirHasSeparator = ( ( dir.lastIndexOf( FILE_SEPARATOR ) ) == dir.length() - 1 );
    boolean fileHasSeparator = ( file.indexOf( FILE_SEPARATOR ) == 0 );
    if ( ( dirHasSeparator && !fileHasSeparator ) || ( !dirHasSeparator && fileHasSeparator ) ) {
      return dir + file;
    }
    if ( dirHasSeparator && fileHasSeparator ) {
      return dir + file.substring( 1 );
    }
    return dir + FILE_SEPARATOR + file;
  }
@Test
  public void testSafeAppendDirectory() {
    final String expected = "dir" + Const.FILE_SEPARATOR + "file";
    assertEquals( expected, Const.safeAppendDirectory( "dir", "file" ) );
    assertEquals( expected, Const.safeAppendDirectory( "dir" + Const.FILE_SEPARATOR, "file" ) );
    assertEquals( expected, Const.safeAppendDirectory( "dir", Const.FILE_SEPARATOR + "file" ) );
    assertEquals( expected, Const.safeAppendDirectory( "dir" + Const.FILE_SEPARATOR, Const.FILE_SEPARATOR + "file" ) );
  }