嗨,我遇到了一个困扰我的错误!
我想要做的是拆分一个使用“;”的文本文件
然后将其存储为 ArrayList,但此错误不断弹出!
package au.edu.canberra.g30813706;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Environment;
import android.widget.EditText;
public class FileReader extends Activity{{
ArrayList<String> sInfo = new ArrayList<String>();
String txtName = "AccomodationTxt.txt";
File root = Environment.getExternalStorageDirectory();
File path = new File(root, "CanberraTourism/" + txtName);
try {
BufferedReader br = new BufferedReader (
new InputStreamReader(
new FileInputStream(path)));
String line;
String[] saLineElements;
while ((line = br.readLine()) != null)
{
//The information is split into segments and stored into the array
saLineElements = line.split(";");
sInfo.add(saLineElements[0], saLineElements[1], saLineElements[2], saLineElements[3], saLineElements[4]);
}
br.close();
}
catch (FileNotFoundException e) {
System.err.println("FileNotFoundException: " + e.getMessage());
}}
}
错误:
The method add(int, String) in the type ArrayList<String> is not applicable for the arguments (String, String, String, String, String)