Android Open Source - BT4Android-trunk File Read

From Project

Back to project page BT4Android-trunk.


The source code is released under:

Apache License

If you think the Android project BT4Android-trunk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/* ww  w .j a v a  2s  . c om*/
import java.util.*;


import android.content.res.Resources;

 * This class sets up all the stop codes actual stop names from a csv file
 * for easier route clarification
public class FileRead {
  public Map<String, String> stops_ = new HashMap<String, String>();

  //reads all the stop codes and route names into the map
  public void readFromFile(Resources myResource) 
    try {
      // Open the file that is the first
      // command line parameter

      InputStream fstream = myResource.openRawResource(R.raw.stops);
      // Get the object of DataInputStream
      DataInputStream in = new DataInputStream(fstream);
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      String strLine;
      // Read File Line By Line

      while ((strLine = br.readLine()) != null) {
        // Print the content on the console
        //String[] allWords;

        StringTokenizer st = new StringTokenizer(strLine, ",");
        stops_.put(st.nextToken(), st.nextToken());


    } catch (Exception e) {// Catch exception if any
      //System.err.println("Error: " + e.getMessage());


Java Source Code List