标签:android class ext com get 使用
private static List<String> getxxxx(Context ctx) {
        try {
Scanner sc = new Scanner(
                    ctx.openFileInput("xxx.txt"));
            ArrayList<String> ret = new ArrayList<String>();
            while (sc.hasNextLine()) {
                ret.add(sc.nextLine());
            }
            sc.close();
 return ret;
        } catch (FileNotFoundException e) {
            return new ArrayList<String>();
        }
    }
openFileInput("xxx.txt") 读取用户保存的内容
Scanner 是一个可以使用正则表达式来解析基本类型和字符串的简单文本扫描器。
Scanner 使用分隔符模式将其输入分解为标记,默认情况下该分隔符模式与空白匹配。然后可以使用不同的 next 方法将得到的标记转换为不同类型的值。
例如,以下代码使用户能够从 System.in 中读取一个数:
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
android学习笔记--Scanner,布布扣,bubuko.com
标签:android class ext com get 使用
原文地址:http://www.cnblogs.com/yuan1225/p/3806329.html