I'm trying to write a class that iterates through a textfile, it looks like this (it's ~5000 lines):
Postnr Poststad Bruksområde Kommunenummer Lat Lon Merknad Nynorsk Bokmål Engelsk 0001 Oslo Postboksar 301 59.91160 10.75450 Datakvalitet: 2. Koordinatar endra 28.09.2012. Oppdatert 04.12.2012 url1 url2 url3 My trouble is: the method getassets is undefined for the type SearchTabTxt
I'm trying to read the file from the assets folder and I can't seem to find a solution to this. I tried to write a search class for this:
public class SearchTabTxt extends AsyncTask<String, Void, ArrayList<String[]>> { protected ArrayList<String[]> doInBackground(String... inputString) { ArrayList<String[]> list = new ArrayList<String[]>(); try { InputStream is = getAssets().open("file.txt"); if (is != null) { String search = inputString[0].toString(); InputStreamReader inputreader = new InputStreamReader(is, "UTF-8"); BufferedReader buffreader = new BufferedReader(inputreader); int antallTreff = 0; while (buffreader.readLine() != null) { ArrayList<String> placeInformation = new ArrayList<String>(); if (buffreader.readLine().contains(search)) { antallTreff++; System.out.println("Found: " + search); placeInformation.clear(); for (String i : buffreader.readLine().split("\t")) { placeInformation.add(i); } System.out.println(placeInformation.get(11)); // Sorry about the Norwegian will rewrite if (antallTreff >= 3) { System.out.println("Did I find something?"); break; } if (buffreader.readLine() == null) { break; } } } } } catch (ParseException e) { Log.e("Error", e + ""); } catch (ClientProtocolException e) { Log.e("Error", e + ""); } catch (IOException e) { Log.e("Error", e + ""); } return list; } }