public static String expand ( String filename ) { if ( filename . startsWith ( "~" + File . separator ) ) { try { String home = System . getProperty ( "user.home" ) ; if ( home != null ) { return home + filename . substring ( 1 ) ; } } catch ( SecurityException e ) { // ignore } } return filename ; }
Expands ~ to the home directory .