CSV file cannot be accessed via BufferedReader in Android -
i trying read csv file using bufferedreader in android. program works fine in java when try read data android following error get.
01-31 17:09:58.466: w/system.err(15912): java.io.filenotfoundexception: /users/sabbir/documents/workspace/testcsv/src/file/input.csv: open failed: enoent (no such file or directory)
following code using here.
public double getlongitudes() { bufferedreader br = null; string line = ""; string cvssplitby = ";"; string[] nextline; double longitudes = 0; try { br = new bufferedreader( new filereader( "/users/sabbir/documents/workspace/testcsv/src/file/input.csv")); while ((line = br.readline()) != null) { // use comma separator string[] country = line.split(cvssplitby); longitudes = double.parsedouble(country[5]); log.d("worked", "worked"); // system.out.println("latitude " + longitudes); } } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } { if (br != null) { try { br.close(); } catch (ioexception e) { e.printstacktrace(); } } } system.out.println("done"); return (longitudes); }}
any idea why happening ??
the path /users/sabbir/documents/workspace/testcsv/src/file/input.csv
invalid. looks path file on computer rather android device. need push file device or emulated device , access there. android emulator not read files directly computer's filesystem.
Comments
Post a Comment