public static String removeLast ( String original , String string ) { int lastIndexOf = original . lastIndexOf ( string ) ; if ( lastIndexOf == - 1 ) { return original ; } return original . substring ( 0 , lastIndexOf ) ; }
This method create nre properties from the origianl one and remove any key with the password then call toString method on this prperties .