File Reader, Android Phone Application -
im having issue file-reader part, im trying split text file stored in sd after store array.
im not sure how proceed in manner.
this have tried far
package au.edu.canberra.g30813706; import java.io.bufferedreader; import java.io.file; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.ioexception; import java.io.inputstreamreader; import java.util.arraylist; import java.util.vector; import android.app.activity; import android.os.environment; import android.widget.edittext; public class filereader extends activity{{ string txtname = "accomodationtxt.txt"; file root = environment.getexternalstoragedirectory(); file path = new file(root, "canberratourism/" + txtname); try { bufferedreader br = new bufferedreader ( new inputstreamreader( new fileinputstream(path))); string line; string[] salineelements; arraylist<string> sinfo = new arraylist<string>(); while ((line = br.readline()) != null) { //the information split segments , stored array salineelements = line.split(";"); sinfo.add(salineelements[0]); sinfo.add(salineelements[1]); sinfo.add(salineelements[2]); sinfo.add(salineelements[3]); sinfo.add(salineelements[4]); } br.close(); } catch (filenotfoundexception e) { system.err.println("filenotfoundexception: " + e.getmessage()); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); }}
}
Comments
Post a Comment