title: read text file method
body: <p>I am an android newby so apologies if this seems trivial, and the lengthy post. I have googled etc but the only android references I can find seem to refer to</p>
  
  <pre><code>InputStream is = getAssets().open("read_asset.txt");
          int size = is.available();
  
          // Read the entire asset into a local byte buffer.
          byte[] buffer = new byte[size];
          is.read(buffer);
          is.close();
  </code></pre>
  
  <p>I tried using this in my class but even after importing java.io.InputStream; it errored on the getAssets().</p>
  
  <p>I am trying to use the rowId of a listview click to;
  open a text file (depends on rowId value),
  read the file line by line,
  generate a string array of the first 16 characters, etc
  then use the array to populate the next activity's listview.</p>
  
  <pre><code>String[] sectID = null; //to be loaded in listview
      switch (rowId){
          case 0://custom, go to section input screen
          case 1:                 
       readSectionFile s = new readSectionFile("Sect_US.dat");
       sectID=s.arrayShapesAll();
  </code></pre>
  
  <p>My readSectionFile class (extract) is;</p>
  
  <pre><code>public readSectionFile(String FileName) {
    //Count the number of section records in the data file
    String line = null;    // String that holds current file line
    int recordcount = 0;   // Line number of count
    try{
        BufferedReader buf = new BufferedReader(new FileReader(FileName));
        // Read file to count records
        while ((line = buf.readLine()) != null){    //null = EOF
            line = buf.readLine();
            if (line.substring(0, 1).equals("*") || line.length() == 0) {      //== comment or blank line
                //do nothing
            }else{
                recordcount++;
            }
        }//while
        buf.close();
    }catch (IOException x){
         x.printStackTrace();
    }//end try
    // Now read file to load array
    mSectionIDArray = new String[recordcount + 1];
    mSectionIdx = new int[recordcount + 1][2];
    mData = new double[recordcount + 1][15];
    int c=0;
    String sectdata = null;    // String that holds current file line
    try {
        BufferedReader buf = new BufferedReader(new FileReader(FileName));
        while ((sectdata = buf.readLine()) != null){           //null = EOF
            sectdata = buf.readLine();
  </code></pre>
  
  <p>The code doesn't work and crashes at readSectionFile s = new readSectionFile("Sect_US.dat");</p>
  
  <p>also, in the readSectionFile code, the second instance of buf generates an Eclipse error asking for a try, catch block, whereas the first instance is accepted.</p>
  
  <p>My questions are,
  Am I going about opening this text file (in /assets) correctly?
  What is wrong with the second buf use?</p>