Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import android.content.Context; public class Main { final public static int nFields = 9; private final static String eol = System.getProperty("line.separator"); final public static String userInfoPath = "companyinfo.txt"; public static String[] userInfo; final private static String separator = "!@#$%^&*()_+"; public static int loadUserInfo(Context c) throws Exception { ArrayList<String> fileContents = new ArrayList<String>(); BufferedReader br; br = new BufferedReader(new InputStreamReader(c.openFileInput(userInfoPath))); String nextLine = br.readLine(); while (nextLine != null) { fileContents.add(nextLine); nextLine = br.readLine(); } br.close(); String[] info = new String[nFields]; for (int i = 0; i < nFields; i++) { info[i] = ""; } int nC = 0; for (String f : fileContents) { if (!f.equals(separator)) { info[nC] += f + eol; } else { info[nC] = info[nC].trim(); nC += 1; } } userInfo = info; return nC; } }