Java中文件中的数组数组

Java中文件中的数组数组,java,android,arrays,file-io,Java,Android,Arrays,File Io,我想从格式为的文件中读取数组 {{"text text text","text text","also text"},{"text text text","text text","also text"},{"text text text","text text","also text"}} 从一个文件,不知道最好的方法来做。如何有效地拆分行以便将它们添加到for循环中的ArrayList中?string.split(“,\\{”)将返回一个以逗号分隔的行中的条目数组。您可以使用该数组和一些嵌套

我想从格式为的文件中读取数组

{{"text text text","text text","also text"},{"text text text","text text","also text"},{"text text text","text text","also text"}}
从一个文件,不知道最好的方法来做。如何有效地拆分行以便将它们添加到for循环中的ArrayList中?

string.split(“,\\{”)
将返回一个以逗号分隔的行中的条目数组。您可以使用该数组和一些嵌套的
for
s来填充
ArrayList
s。虽然如果要保存到Android,您应该使用SharedReference和保存项目集

共享优先权的示例:

    // Adds an item to the shared preferences list
    public void addItemToList(String item){
        SharedPreferences itemList = getSharedPreferences(PREFS_NAME, 0);
        Set<String> items =  itemList.getStringSet(filter, new HashSet<String>());
        Set<String> tItems =  new HashSet<String>();
        tItems.addAll(items); 

        tItems.add(item);

        SharedPreferences.Editor editor = itemList.edit();
        editor.putStringSet(filter, tItems);

        editor.commit();
    }
//将项目添加到共享首选项列表中
公共无效附加项列表(字符串项){
SharedReferences itemList=GetSharedReferences(首选项名称,0);
Set items=itemList.getStringSet(过滤器,新HashSet());
Set tItems=新的HashSet();
tItems.addAll(项目);
添加(项目);
SharedReferences.Editor=itemList.edit();
编辑器.putStringSet(过滤器,滴度);
commit();
}
嵌套对象的示例:

String[] lineArray = line.split(",\\{");
for(int i =0; i < lineArray.length ; i++){
    String[] currentArray = lineArray[i].split(",");
    for(int j = 0; j < currentArray.length ; j++){
    ....
String[]lineArray=line.split(“,\\{”);
对于(int i=0;i