public static final Set < ? extends OpenOption > getOpenOptions ( Path path , Map < String , ? > env ) throws IOException { Set < ? extends OpenOption > opts = ( Set < ? extends OpenOption > ) env . get ( OPEN_OPTIONS ) ; if ( opts == null ) { if ( Files . exists ( path ) && Files . size ( path ) > 0 ) { opts = EnumSet . of ( READ ) ; } else { opts = EnumSet . of ( WRITE , CREATE ) ; } } return opts ; }
Returns open - options . Returns from env if exists . Otherwise if file exists and size greater than 0 returns READ or READ WRITE .