java - Android Studio Reading from Raw Resource Text File -
i'm trying maintain .txt file in res\raw file in android studio , read/parse file. have file "my_file.txt" in folder called "raw" created in "res" directory (that didn't create).
here's think main issue is: when creating file object (to utilize scanner object), path should pass in text file?
here's code:
private void readfile(){ scanner scanner = null; seek { scanner = new scanner(new file("\\res\\raw\\my_file.txt")); //i've tried without .txt extension log.v("readfile->try","trying read file."); }catch(exception e) { //send error message. } if(scanner != null) { while (scanner.hasnext()) { string[] line = scanner.nextline().split("\t"); //process string here } } }
think looking along lines of
inputstream = ctx.getresources().openrawresource(res_id);
where ctx instance of context
java android android-studio
No comments:
Post a Comment