public static Map < String , String > getContentMap ( File file , String separator ) throws IOException { List < String > content = getContentLines ( file ) ; Map < String , String > map = new LinkedHashMap < String , String > ( ) ; for ( String line : content ) { String [ ] spl = line . split ( separator ) ; if ( line . trim ( ) . length ( ) > 0 ) { map . put ( spl [ 0 ] , ( spl . length > 1 ? spl [ 1 ] : "" ) ) ; } } return map ; }
Get content of a file as a Map&lt ; String String&gt ; using separator to split values