Basically I have a .txt file on srcard and I want to read that specific file and save all the values that the file has, into a String array. How can I succeed that?
P.S: File has the values divided by white space.
Basically I have a .txt file on srcard and I want to read that specific file and save all the values that the file has, into a String array. How can I succeed that?
P.S: File has the values divided by white space.
If you want to split it with white space then you can use stringtokenizer or string split in the readLine() output. If you want to split it with some pattern then you can use regex in the readLine() output.
use this
File dir = Environment.getExternalStorageDirectory();
File yourFile = new File(dir, "path/file.txt");
FileInputStream fis = new FileInputStream(yourFile);
byte[] data = new byte[(int) yourFile.length()];
fis.read(data);
fis.close();
String str = new String(data, "UTF-8");
String[] array = str.splite(" ");