public static byte[] readData(InputStream stream, String section ) throws IOException {try {StringBuilder sectionText = new StringBuilder();boolean inSection = false;int c = stream.read();while ( c != -1 ) {switch ( c ) {case '[':inSection = true;break;case '\n':case '\r':inSection = false;sectionText = new StringBuilder();break;case ']':inSection = false;if ( sectionText.toString().equals( section ) ) return readData( stream, '[' );sectionText = new StringBuilder();break;default:if ( inSection ) sectionText.append( (char) c );}c = stream.read();}} finally {stream.close();}throw new IOException( "Section '" + section + "' not found" );}
public static byte[] ReadData(Stream stream, String section ){try{StringBuilder sectionText = new StringBuilder();bool inSection = false;int c = stream.ReadByte();while ( c != -1 ){switch ( c ){case '[':inSection = true;break;case '\n':case '\r':inSection = false;sectionText = new StringBuilder();break;case ']':inSection = false;if (sectionText.ToString().Equals(section)){return ReadData(stream, '[');}sectionText = new StringBuilder();break;default:if ( inSection ) sectionText.Append( (char) c );break;}c = stream.ReadByte();}}finally{stream.Close();}throw new IOException( "Section '" + section + "' not found" );}