int i = input.lastIndexOf( 'r' ); int j = input.lastIndexOf( 'w' ); if( j > i ) i = j; j = input.lastIndexOf( 'a' ); if( j > i ) i = j;  if( i > 0 ) filemode = input.substring( i, i+1 );  return filemode;
for (int i = 1; i < input.length(); i++ ) { char ch = input.charAt(i); switch (ch) { case 'r': filemode = "r"; break; case 'w': filemode = "w"; break; case 'a': filemode = "a"; break; case 'b': modifier = "b"; break; case 't': modifier = "t"; break; } } return filemode + modifier;
  private String getFileMode( String input )  {    String filemode = input.substring( 0, 1 );    if( "x".equals(filemode) )      filemode = "w";    int i = input.lastIndexOf( 'r' );    int j = input.lastIndexOf( 'w' );    if( j > i )      i = j;    j = input.lastIndexOf( 'a' );    if( j > i )      i = j;    if( i > 0 )      filemode = input.substring( i, i+1 );    return filemode;  }