Here you can see ive used the BufferedReader method to impotr contacts from an external file, but i keep getting the repeated errors -
not a statement, illegal start of expression and ';' expected.
can anybody help?
public void importContacts(){
try{
BufferedReader import = new BufferedReader(new FileReader("example.buab"));
int i = 0;
String contacts;
while (( contacts = import.readLine()) != null)
{
temp.add(contacts);
开发者_JS百科 i++;
}
int a = 0;
int b = 0;
for (a = 0, b = 0; a < temp.size(); a++, b++)
{
if (b == 4)
{
b = 0;
}
if (b == 0)
{
Name.add(temp.get(a));
}
if (b == 1)
{
Phone.add(temp.get(a));
}
if (b == 2)
{
Mobile.add(temp.get(a));
}
if (b == 3)
{
Address.add(temp.get(a));
}
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
txtname.setText(Name.get(0));
txtnum.setText(Phone.get(0));
txtmob.setText(Mobile.get(0));
txtadd1.setText(Address.get(0));
}
Your BufferedReader
variable is called import
, and that's a reserved word - you can't use it for variables.
精彩评论