Ini File Stream Reader : Stream « File « Android

Ini File Stream Reader

 * Transport map viewer for Android platform
 * Copyright (C) 2009-2010 Roman Golovanov and other
 * respective project committers (see project home page)
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <>.
//package org.ametro.model.util;


public class IniStreamReader {

  private static final int BUFFER = 8196;
  private final BufferedReader mStream;
  private String mSection;
  private String mKey;
  private String mValue;
  private boolean mSectionChanged;
  public IniStreamReader(InputStreamReader stream) throws IOException{
    mStream = new BufferedReader(stream, BUFFER);
    mSection = null;
    mValue = null;
    mSectionChanged = false;
  public String getSection(){
    return mSection;

  public String getKey(){
    return mKey;
  public String getValue(){
    return mValue;
  public boolean isSectionChanged(){
    return mSectionChanged;
  public boolean readNext() throws IOException{
    String line = mStream.readLine();
    boolean hasResult = false;
    mSectionChanged = false;
      line = line.trim();
      if(line.length() != 0){
        if(line.startsWith("[") && line.endsWith("]") ){
          mSection = line.substring(1, line.length() - 1);
          mSectionChanged = true;
        }else if( line.indexOf('=')!=-1 && !(line.startsWith("#") || line.startsWith(";")) ) {
                  String[] parts = line.split("=");
                    mKey = parts[0].trim();
                    mValue = parts.length > 1 ? parts[1].trim() : "";
                    hasResult = true;
      line = mStream.readLine();
    return hasResult;


Related examples in the same category

1.Playing Back Audio Streams
2.Stream Proxy
3.Copy Stream
4.Read InputStream fully to a string
5.Read Stream to byte array String From Stream
7.Read stream Fully
8.Read InputStream with ByteArrayOutputStream
9.get Resource As Stream, Loads the resource from classpath
10.InputStream to byte array, copy Reader and Writer,
11.InputStream that notifies listeners of its progress.
12.String to InputStream
13.Context.getFileStreamPath To String To Bytes
16.Load/save Int Map Data
17.Write InputStream into a StringBuilder