java - FileNotFoundException when loading textfile into android project -
i've been working on android bid page app class , can't seem find out why program throws filenotfoundexception when path correct (relative path). i'm using class read in file contains string values of item objects , create items put temporary hashmap , return it. in advance!!
public class fileloader { private file path = new file("items"); private static file textfile; //filename called "allitems.txt" public fileloader(string filename) { textfile = new file(path, filename); } public map<integer, item> getitems() { //item custom object map<integer, item> items = new hashmap<integer, item>(); int = 1; try (bufferedreader bf = new bufferedreader(new filereader(textfile));) { string itemtoparse; while((itemtoparse = bf.readline()) != null) { //itemparser custom static class create item 1 string items.put(i, itemparser.parseitem(itemtoparse)); i++; } } catch (filenotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } return items; } }
Comments
Post a Comment