private void loadStream ( InputStream stream ) { int iPos = - 1 ; String strLine = null ; String strSection = null ; String strRemarks = null ; BufferedReader objBRdr = null ; InputStreamReader objFRdr = null ; INISection objSec = null ; try { objFRdr = new InputStreamReader ( stream ) ; if ( objFRdr != null ) { objBRdr = new BufferedReader ( objFRdr ) ; if ( objBRdr != null ) { while ( objBRdr . ready ( ) ) { iPos = - 1 ; strLine = null ; strLine = objBRdr . readLine ( ) . trim ( ) ; if ( strLine == null ) { } else if ( strLine . length ( ) == 0 ) { } else if ( strLine . substring ( 0 , 1 ) . equals ( ";" ) ) { if ( strRemarks == null ) strRemarks = strLine . substring ( 1 ) ; else if ( strRemarks . length ( ) == 0 ) strRemarks = strLine . substring ( 1 ) ; else strRemarks = strRemarks + "\r\n" + strLine . substring ( 1 ) ; } else if ( strLine . startsWith ( "[" ) && strLine . endsWith ( "]" ) ) { // Section start reached create new section if ( objSec != null ) this . mhmapSections . put ( strSection . trim ( ) , objSec ) ; objSec = null ; strSection = strLine . substring ( 1 , strLine . length ( ) - 1 ) ; objSec = new INISection ( strSection . trim ( ) , strRemarks ) ; strRemarks = null ; } else if ( ( iPos = strLine . indexOf ( "=" ) ) > 0 && objSec != null ) { // read the key value pair 012345=789 objSec . setProperty ( strLine . substring ( 0 , iPos ) . trim ( ) , strLine . substring ( iPos + 1 ) . trim ( ) , strRemarks ) ; strRemarks = null ; } else { objSec . setProperty ( strLine , "" , strRemarks ) ; } } if ( objSec != null ) this . mhmapSections . put ( strSection . trim ( ) , objSec ) ; this . mblnLoaded = true ; } } } catch ( FileNotFoundException FNFExIgnore ) { this . mhmapSections . clear ( ) ; } catch ( IOException IOExIgnore ) { this . mhmapSections . clear ( ) ; } catch ( NullPointerException NPExIgnore ) { this . mhmapSections . clear ( ) ; } finally { if ( objBRdr != null ) { closeReader ( objBRdr ) ; objBRdr = null ; } if ( objFRdr != null ) { closeReader ( objFRdr ) ; objFRdr = null ; } if ( objSec != null ) objSec = null ; } }
Reads the INI file and load its contentens into a section collection after parsing the file line by line .